How to Create a WordPress Child Theme | Step by Step

Follow the following steps to create a WordPress child theme.

Step 1: Go to your themes folder

Step 2: Choose a theme you want to have a child theme

Watch the following video that covers the whole process of creating a child theme. Either way, continue on the rest of the steps:

Step 3: Create a new folder for the child theme.

Any name will do. The folder should be the same folder as your parent theme (not inside).

Step 4: Create two files inside the child theme folder.

Create a functions.php and style.css files inside the folder.

Step 5: Refer to the WordPress Theme Handbook.

Copy and paste the example theme basic info into your style.css file.

  1. /*
  2. Theme Name: Twenty Fifteen Child
  3. Theme URI: http://example.com/twenty-fifteen-child/
  4. Description: Twenty Fifteen Child Theme
  5. Author: John Doe
  6. Author URI: http://example.com
  7. Template: twentyfifteen
  8. Version: 1.0.0
  9. License: GNU General Public License v2 or later
  10. License URI: http://www.gnu.org/licenses/gpl-2.0.html
  11. Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready
  12. Text Domain: twentyfifteenchild
  13. */

Copy and paste the enqueue function into your functions.php file.

  1. add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
  2. function my_theme_enqueue_styles() {
  3.  
  4. $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.
  5.  
  6. wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
  7. wp_enqueue_style( 'child-style',
  8. get_stylesheet_directory_uri() . '/style.css',
  9. array( $parent_style ),
  10. wp_get_theme()->get('Version')
  11. );
  12. }

Step 6: Go to the wordpress admin dashboard and activate your child theme.

When you visit the website, it should the same as when the parent theme was activated. You’re done!

Done!

Now you can create modifications/changes in your child theme without affecting the parent theme’s core files.

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *