The safest and the easiest way to modify or customise any of my themes is by creating a child theme. You are using a child theme are you not?
The nice thing of customising your own theme is that apart from changing the look of the your theme, you could also be picking up some coding skills should you not already have them. The day we stop learning something new should be the day we all dread.
If you are here looking to see where I added custom hooks and actions in my themes you are in for a surprise, there aren’t any. Hooks and actions are very effective but I do not use them in my themes. Through the years the majority of WordPress users I have had the privilege of working with have all been non-coders and most of them would not understand hooks and actions. For the sake of these users I use code partials in my themes instead of hooks and actions. More about code partials a bit further down.
One of the first things you can do to make your theme uniquely yours is to head over to the Customizer. My themes will have different Customizer Options but the options will allow you to make tweaks to your theme with just a click of the mouse.
Making changes to any theme via the stylesheet is very often the way to go and nine times out of ten this will be all that is required. The stylesheets in my themes all have a meaningful table of contents and the CSS elements are sorted alphabetically within function ( I make use of CSS Comb for this). All of this makes it easy to find the styling you need to change.
I make all the functions that you could use to make changes to your theme pluggable. This means that you can change functions to do whatever you need them to do.
All you have to do is to find the relevant function, copy it’s original code from the parent theme and paste this into your child themes functions.php. Make sure you leave the name of the function unchanged.
Now you can change the code to suit your own needs. You could also simply leave an empty stub of the function in your child theme and this will effectively remove the function.
As users experience problems or have queries I will continually add articles to this site to explain how things should be done. I would imagine that changing functions will form the bulk of the queries so keep checking to see if I have not already published a solution to your problem.
Most of the functions you could need to make changes will most likely be found in /template-parts/template-functions.php and /template-parts/template-tags.php.
In an effort to keep my code DRY (do not repeat yourself) I always make use of so-called code partials in my themes. This is handy for you as well, you can now locate the relevant code partial you want to change, copy its content and paste it into a new file which you save in your child theme. Please remember to keep the file name unchanged and place the file in the same directory you found it in.
You could even replace entire template files and change the position of where code partials are being called. This should only be relevant if you are making major changes.
The code partials in my different themes will most probably all be different.
This portion is much the same as the code partials except here you will be replacing template files in their entirety e.g. header.php, footer.php etc.
Obviously all this sounds easier than what it might actually be. It all depends on the changes you need in your child theme. The basics however remain the same.
When you have finished changing your child theme you should have just the following files:
- The file style.css – with just the changes you made to your theme, you definitely do not have to replace the entire stylesheet.
- The file functions.php – with all the pluggable functions you changed if applicable.
- Any code partial or template file you might have altered. Please remember that these files need to have the original file name and they need to be placed under the same directory structure as used in the parent theme. You might not need any of these files.
That’s it, you should now have the theme you always wanted. Happy customisation.