WordPress has almost become the standard when it comes to creating simple and medium-complex websites. Last but not least, the tons of ready-made themes make life easier for the website creator. Nevertheless, the inclined user would like to make a few adjustments here and there. With a few simple steps you can adapt a theme perfectly to your own ideas.
Requirement: FTP access
FTP access to the website’s files is the basic requirement for making changes to a theme. In your WordPress installation, you can find all installed themes under the path wp-content / themes and there you also have access to all PHP files that are not displayed by default in the WordPress backend.
Be careful when adapting themes
But be careful! If you make changes to an existing theme, you run the risk that these will be overwritten with the next theme update. The safest and most practical way is to create a child theme.
Step 1: create theme folder
To create a child theme, you first need a new theme folder. You save this under the same path under which all other themes can be found: wp-content / themes. You can basically name the folder whatever you want. For the sake of order and findability, most of them give it the name of the parent theme folder and append a “-child” or “-child-theme”.
Step 2: Linking to the Parent Theme
Next you create an empty CSS file, e.g. in the text editor on your local computer, name it style.css and insert the following lines:
You also need a file called functions.php, in which you add the following code:
This will import the CSS data from the parent theme. If you don’t feel so confident in PHP, you can do that in the new CSS file via @import. WordPress officially recommends the PHP method. Importing the parent stylesheets is not a must.
You can of course also write a completely new stylesheet at this point. Most of them just add to their changes. First of all, you can move the new style.css and functions.php into your newly created theme folder.
Step 3: Check the WP backend and look forward to it
The child theme is now visible in the WordPress backend and can be activated. In the editor you will then also find the files you have just created and can make further adjustments.
Further adjustments in other files
The child theme pulls all data from the parent folder. If further adjustments are to be made, for example in the header.php or the index.php, simply copy the corresponding PHP file from the parent folder and paste it into the child directory. The file in the child theme then overwrites the file of the same name from the parent. It also appears in the back office editor. Adjustments can now be made here without the change being overwritten with the next update.
You can also create your own templates and add them to the child directory.
In contrast to all other files, you do not have to copy the functions.php completely, but simply create them from scratch as described above. If you create a new functions.php file in your child folder, the functions.php of the parent will continue to be executed, directly after calling the file from the child folder.
Conclusion: always stay nice and clean
Creating child themes is not rocket science, and it is also a “clean” way to tinker with your WordPress theme.