How to create a WordPress Child Theme and what it is used for

Creating a WordPress Child Theme is an excellent strategy for customising the main theme of your website without directly modifying the original theme file. In this article, we will guide you step by step on how to create a WordPress Child Theme and customise it for your website.
Step 1: Create the Child Theme folder
To create a Child Theme, a new folder must be created within the directory wp-content/themes
of your website. Open the FTP editor or File Explorer and create a new folder with a unique name (e.g. 'my-child-theme').
Step 2: Create the style.css file
The style.css
is the main file of your Child Theme, where you can customise the style of your website. Open the file style.css
within the Child Theme folder and add your CSS changes.
Step 3: Create the functions.php file
The functions.php
is the file that contains the custom functions you wish to execute in your Child Theme. Open the file functions.php
inside the Child Theme folder and add your custom functions.
Step 4: Specify the name and version of the Child Theme
Open the file style.css
and add the following lines of code to the beginning of the file:
/* Theme Name: My Child Theme Theme URI: https://example.com/my-child-theme Version: 1.0 Author: Your Name Author URI: https://example.com */
Save the file.
These lines of code specify the name, URI, version, author and author URI of your Child Theme.
Step 5: Activate the Child Theme
To activate your Child Theme, go to the 'Appearance' section of the WordPress administration panel and select 'Child Themes' in the 'Themes' section. Find your Child Theme in the list and click the 'Activate' button to activate it.
Step 6: Customise the Child Theme Style
Once you have activated your Child Theme, you can customise the style using CSS changes in the style.css
. You can also use the custom functions defined in the functions.php
to customise your user experience.
Step 7: Update the Main Theme
If you wish to update the main theme, you can simply replace the main theme folder with the new version. Your Child Theme will remain unchanged and continue to function correctly.
Tips and tricks
- Make sure you save your files
style.css
efunctions.php
in both the Main Theme and Child Theme folders. - Use a unique name for your Child Theme folder to avoid conflicts with other themes.
- If you wish to use a custom function defined in the
functions.php
of the main theme, be sure to declare it as local within your Child Theme. - To maintain the changes to your administration panel pages, create a copy of the original management files (e.g,
header.php
,footer.php
etc.) within the Child Theme folder.
In this way, you have created a customised Child Theme for your WordPress website!
Need help? Write to info@halkoo.com to receive a customised quote for your new website or e-commerce shop.