Search the site:

Copyright 2010 - 2024 @ DevriX - All rights reserved.

Creating a Child Theme and Making Changes to Functionality: A Basic Guide

Creating child theme

WordPress is a great CMS widely used by a number of people around the world, but when it comes to changing the style or functionality, you’ll need to learn how to do that in the correct manner – when you want your changes to prevail even when you migrate to some other theme, update plugins and make any other changes to your website.

Creating child theme

You can modify your site’s style by making changes to the child themes, and will need to use a functionality plugin to make any changes to your site functionality. However, you need to ensure that the changes take place correctly, so that they still persists after making changes to your website theme.
In this post we’ll talk about the process of creating a child theme and ways to add functionality into your site.

How to Create a Child Theme?

You can find dozens of WordPress themes available on the web, the themes can be really amazing but making even little changes to any one of the themes can prevent you from updating it in the future. Wondering why? That’s because, updating a theme may result in losing all of the changes you’ve made. However, this problem can be solved with the help of “child themes”.

Child themes allow you to utilize your selected theme’s functionality while enabling you to update the theme, without losing your changes.

Child themes inherit features from a parent theme. In case you’re using child theme, then WordPress will look into your child theme first to ensure whether some specific functionality exists or not. If not, then WordPress will use the parent theme instead. This lets you make modifications according to your own needs.

In order to create a child theme, just follow the below listed steps:

1. Navigate to your theme directory. Next, create a folder for the new theme (i.e. child theme). You can assign any name to the theme you’ve created. For example, you can name the theme as mynewchildtheme.

2. Now you’ll have to create a stylesheet that contains information about child theme. Copy and paste the following code into the file you’ve just created:

Theme Name: Child Theme
Theme URI:
Description: My first child theme
Author: Anonymous
Author URI:
Template: xyz
Version: 1.0.0

3. Obtain the styles of your parent theme

After completing the steps, you can activate your child theme. And your site will have the same look and feel as before, however it will now be using your child theme.

Making Changes to the Theme Functionality

There are two types of functionality that you probably would like to add into your website: functionalities that you want to persist even when switching the themes, and ones that applies to your existing theme.
In this post we’ll only discuss about how to deal with the functionality changes that only apply to your existing theme.

Any changes to the functionality are stored within your child theme’s functions.php file. And so, when you’ll check the template for the child theme, you will see that it already contains a functions.php file – having one function in it. This function is used to load your parent theme’s stylesheet.

For instance, let’s say, you want to add a code snippet in the functions.php file for disabling the functionality to receiving comment notifications – when you’re the website administrator. In that case your functions.php will look like as follows:

function load_parent_theme_css() {
wp_enqueue_style( 'parent-theme', get_template_directory_uri() . '/style.css' );
add_action( 'wp_enqueue_scripts', 'load_parent_theme_css' );
function pref_dont_email_webmaster( $emails, $comment_id ) {
$webmaster_email = get_option('admin_email');
if ( $emails[0] == $webmaster_email )
return (array) $emails;
add_filter( 'comment_moderation_recipients', 'pref_dont_email_webmaster', 10, 2 ); 

It’s quite easy to add new snippets in the functions.php file. But, what if your parent theme has a built-in function you would like to change? But you can’t make edits to the parent theme files. What’s more? You can’t even copy the function in your functions.php file and make changes to it as per your own requirements. That’s because, you cannot declare the same function more than once – or it will result in a PHP error.

Making modifications to the functions in parent themes relies upon whether the theme is built correctly or not. In fact, all the functions in parent theme should be enclosed in an if ( ! function_exists() ) statement. This will ensure that in case a custom function with the same name is declared in your child theme’s functions.php file, then the PHP code will avoid the same function in the parent theme.

Now, let’s have a look at the parent theme’s functions.php file and see whether the functions are enclosed in the conditional statements or not:

<?php if ( ! function_exists( 'pinboard_enqueue_styles' ) ) {
function pinboard_enqueue_styles() {
wp_enqueue_style( 'pinboard' );
if( pinboard_get_option( 'lightbox' ) )
wp_enqueue_style( 'colorbox' );
wp_enqueue_style( 'mediaelementplayer' );
add_action( 'wp_enqueue_scripts', 'pinboard_enqueue_styles' );

If the functions are wrapped in conditional statements, then you can copy the function (you want) into your child theme’s functions.php from your parent theme. Moreover, you can make edits within the function and just save them.
In case the functions in your parent theme’s functions.php file are not wrapped in the conditional statements, then get in touch with your theme developer and ask to update the theme as per the WordPress guidelines. This will ensure that no one can override the functions in the child theme’s functions.php file.

WordPress Child Themes Overview

When running a WordPress powered site, we make changes to the site at some point of time: use a theme to modify the appearance of your website and/or add additional functionalities into the site. No matter, what sort of changes we want to make on our website, it is very important to have the right knowledge of – what kind of changes we want to make to the site and how?

If you want to make changes to the theme style or functionalities and want the changes to remain intact even when the theme is changed, you’ll need to create a child theme. When it comes to changing the functionality of a site: we can either make changes to the child theme’s functions.php or rather use a functionality plugin. Reading this post will hopefully provide you with a basic understanding of creating a child theme and how you can make edits to your site functionality.

Sarah Parker is a WordPress developer and do blogging as hobby. She loves sharing her experiencing in writing information-rich blogs on converting HTML to WordPress theme services. Currently, she is employed with Designs2HTML Ltd, that has delivered top-grade markup conversion services since 8 years.