How to create and use wordpress child themes

Wordpress themes

How to create and use WordPress child themes

A WordPress child theme is a theme that inherits the functionality of another theme, called the parent theme. Child themes allow you to modify, or add to the functionality of that parent theme. A child theme is a safest and easiest way to modify an existing theme, whether you want to make a few tiny changes or extensive changes. Instead of modifying the theme files directly, you can create a child theme and override within.

Why use a Child Theme?

Here are a few reasons:

If you modify an existing theme and it is updated, your changes will be lost. With a child theme, you can update the parent theme (which might be important for security or functionality) and still keep your changes.

It can speed up development time.

It’s a great way to get started if you are just learning WordPress theme development.

How to Create a Child Theme

Child Theme directory structure create a directory in your themes directory to hold the child theme. The theme directory is wp-content/themes. You should name the directory without any space as part of the name, and it is common practice to use the name of the parent theme folder with “-child” appended to it. For example, if you are making a child of the twenty fourteen themes, your folder name would be twenty fourteen-child.

Overriding Parent Theme Template Files

To override the template files in the parent theme, open the original template file and save a copy to the child theme folder with the same file name and folder structure. The file structure has to match with the parent theme.

FOR EXAMPLE:

let’s say you want to edit the loop.php file in the parent theme and it is stored in the “includes” folder

open the loop.php file and save a copy in the “includes” folder of the child theme

edit and save the loop.php in the child theme

FOR ANOTHER EXAMPLE:

let’s say you want to edit the page.php

open the page.php file and save a copy in the child theme

edit and save the page.php in the child theme

HERE ARE SOME OF THE TEMPLATE FILES THAT YOU CAN OVERRIDE:

header.php

footer.php

index.php

single.php

page.php

sidebar.php

includes/loop.php

includes/slider.php

Child Theme functions.php (optional)

If you need add additional PHP functions, create a functions.php in the child theme folder. It will load in addition to the parent theme functions.php file.

<?php

/* custom PHP functions below this line */

?>
Activating The Child Theme

Finally, activate the child theme at Appearance > Themes.

Let’s chat about your project

Mail To Us

Our Skype Id
uniqwebtech

Get in touch, the kettle is always on.

    Website DesignDigital Marketing

    Website DevelopmentBranding / Design