How to make a wordpress child theme

Making a WordPress Child Theme

Making a WordPress Child theme is fairly simple, we will go through them step by step.

Why do I need a child theme?

There are several reasons why you would like a child theme. First, making changes to a theme is not recommended by WordPress. Second, if you change the parent theme directly when you update the theme all of your changes are lost. Third is security, many updates are bug fixes, but some are because of security.

How do I make a child theme?

You can use a plugin to generate the needed files or you can do it yourself. Seeing that this is a learning site I will take you through it step by step. I am going to use TwentyThirteen just as an example, you can use the theme of your choice. Just remember when it says twentythirteen you would substitute your parent theme name for it.

Make a Directory

Make a directory / folder and name it – thirteenchild (or the name of your parent theme and child). Put this file in  www ->Your Directory Name -> wp-content -> themes (you should see the parent theme there). See my former article on setting up your development environment.

Make the functions.php file

Now we  are going  to make two files: functions.php and style.css you can do this in your favorite code editor or if you are on Linux you can simply go to  the command prompt – go to the directory and “touch” the two files to make them.

Now that we have them we need to edit them to make them more useful. Let’s take the functions.php and make a couple of functions to let it see the parent:

Save that.

Mark up the style sheet

First open up the style.css and write this in:

Now, just save the style sheet in the root directory.

Screenshot.png

  1. Now we are going to make an  image to go along with our theme – time to get out your favorite image manipulation program. Mine is GIMP, you can use your favorite.
  2. Next we are going to make an image that is 880 x 660 pixels. You can go larger if you want but this seems to be the standard size.  You can take a screenshot of your completed site after you complete it – right now I am just going to make one.
  3. Next, Save the png as screenshot.png
  4. Once you have your child theme looking the way you want it you can take a screen shot of it and make that your screenshot.png or you can leave your screen shot alone.

Now,  upload it to your production server you need to .zip up the directory you have it in. This will help keeping it together while WordPress does the rest.

Go to your dashboard on your production server (where your website is hosted) – click on “Appearance” -> “Themes”

Click the “Add New” button

Click the “Upload Theme” button

Search your local computer for the zip file you created and click the “Install Now” button.

The final step is to “Activate” your new child theme

That is all there is to it. It is much more fun doing it by scratch than getting yet another plugin that you are only going to use once.

These are the basic files that you need for the theme. You can add others like the header.php and the footer.php to give yourself a custom header and footer, but these are extra files.

Here are all of the files zipped up for you so you can see them, and learn from the example.

How useful was this post?

Click on a star to rate it!

Average rating 5 / 5. Vote count: 1

No votes so far! Be the first to rate this post.



Updated on October 28, 2021