Mini-WordPress Logo Belongs Here

Creating a WordPress 4.x Child Theme.

Why do You need to Create a WordPress Child Theme ?

Two reasons.

  1. Maintaining a complete theme can be a large job.
  2. Modifying core WordPress Templates is futile.  Every update will overwrite your modifications, forcing You to re-implement all Your changes.

What is the bare minimum You need for a child theme?

  • a folder for Your theme
  • functions.php
  • style.css

Step 1:   Create a folder for your theme. This folder needs to be created inside the WordPress themes folder.  The themes folder is inside the wp-content folder of Your wordpress installation

You can use any name You want, but I advise using “parent-theme”-child as your folder name.  In my case my child theme’s folder name is twentytwelve-child . This just makes things less complicated in the long run.

It will look like this when done correctly

"wp-content-

wp-content-> themes-> Your theme’s folder

Note: this folder’s permissions need to be set as 755

Inside that folder lets create 2 files.

  1. style.css
  2. functions.php

Step 2: Create the style.css file inside Your template folder.  Your style.css needs to contain the following. TAKE NOTE: The contents below are tailored to Twenty Twelve Template parent template. (Note: set the file permissions to 644)

*** Also remember to change example.com to your domain name!!!

/*
 Theme Name:   Twenty Twelve Child
 Theme URI:    http://example.com/twentytwelve-child/
 Description:  Twenty Twelve Child Theme
 Author:       John Doe
 Author URI:   http://example.com
 Template:     twentytwelve
 Version:      1.0.0
 Tags:         light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
 Text Domain:  twenty-twelve-child
*/

Step 3:   You need to create a functions.php file inside Your template folder.  Your child theme’s function.php needs to contain the following. (Note: set the file permissions to 644)

<?php

add_action( 'wp_enqueue_scripts', 'enqueue_parent_theme_style' );
function enqueue_parent_theme_style() {
    wp_enqueue_style( 'parent-style', get_template_directory_uri().'/style.css' );
}

That is it!  You can now go activate your child theme from the list of installed WordPress themes.  Now its time to start tinkering.  Stay Posted for the next WordPress article!

Leave a Reply

Your email address will not be published.