719-646-4524 in Colorado Springs

Imagine creating the perfect customized WordPress website, but you didn’t create a child theme. The next time you update your theme or WordPress installation, you may find disaster. This is because updates overwrite files with new versions. So, if you customized any of those files, then all of that customization you created for your site will be GONE.

You may have seen a “child theme” mentioned in an article or forum. We mention them in many articles. Why? Because they are so important. As I mentioned before, not having a child theme can equal disaster.

Getting Started With Your Child Theme

A child theme does not take the place of your theme. Instead it’s used to make changes to your website without changing the theme itself. It allows you to create and add additional styles, scripts, and also to modify php.

Be aware that there is another “old” way to create a child theme that uses @import url(“../themename/style.css”); however, this is no longer considered best practice due to the fact that it adds to site load times.

Your child theme will eventually reside in:

YourHost/wp-content/themes/

along with the theme you want to use. You have the option of adding the files there or creating them locally and moving them over using WordPress. The initial steps are the same.

  1. First of all, create a Folder (Directory) called YourThemeName-child. This is so that you have ease of associating the theme with its child. You can actually name it whatever you want.
  2. Go into the YourThemeName-child directory and create a style.css file.
  3. Copy/paste the following into the style.css file:
    /*
     Theme Name:   Shanora Child
     Theme URI:    http://shanora.net/shanora-child
     Description:  Shanora Child Theme
     Author:      Shanora Networks
     Author URI:   http://shanora.net
     Template:     Shanora
     Version:      1.0.0
     License:      GNU General Public License v2 or later
     License URI:  http://www.gnu.org/licenses/gpl-2.0.html
     Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
     Text Domain:  shanora-child
     */
     

    Theme name (required): the name of the theme plus the word child, makes it easier to associate and remember – this should match the name of the folder/directory you created in step one.
    Theme URI (optional): the URL where users can find more information on the theme.
    Description (optional): This is a short description off the theme.
    Author (optional): Your name
    Author URI (optional): Your URL
    Template (required): The name of the parent theme directory/folder
    Version (optional): The version number of your child theme, if you desire to have one.
    License (optional): The theme’s license
    License URI (optional): The URL of the license.
    Tags (optional): Any words or phrases that would allow users to better find your theme.
    Text Domain (optional): The string used for textdomain for translation

    You can now add any custom css after the header information.

  4. Save your style.css file
  5. In the same Folder/Directory create a file called functions.php
  6. Copy/paste the following into your new functions.php file:
    <?php
    add_action( 'wp_enqueue_scripts', 'shanora-child_enqueue_styles' );
    function shanora-child_enqueue_styles() {
        wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
    
    }
    

    You may change the shanora_child so that it reflects your theme name. From here on, this file is where you will add any enqueueing, changes to the original functions.php, or additions to the functions.php in this file.

  7. Save your functions.php
  8. This is all you need for your child theme to work. Furthermore, you can always add other files such as:
    • A css directory to hold additional stylesheets.
    • A js directory to hold javascript files you may need to reference.
    • Header.php
    • Footer.php
    • Index.php
    • Page.php
    • An Includes directory to hold any files you may want to edit.
    • Sidebar.php
  9. You can add the files as needed. Consequently, it is best to only include the files you will definitely be using.

Finishing Up

If you edited the files directly in your theme’s folder/directory, then you should see a new child theme available in the Appearance >> Themes area of your WordPress admin panel. So, go ahead and activate! You’re ready to go.
For those who didn’t edit within the directory, as the final step to creating your child theme, you will need to zip up your child theme folder/directory.
Once you have your zip file, you can go into your WordPress administration panel and go to Appearance >> Themes. Click on add new and add your newly created child-theme. Lastly, activate the child theme to begin using your theme without the fear of update loss!

Download Our Sample Child Theme

If you want, you can also install our sample child theme and make the changes to reflect the theme you are using!