SiteCozy

  • My account

How to create a child theme of your wordpress theme?

2018-10-16

1 Open a file manager or an FTP client

2 From the root folder, go to /wp-content/themes

3 Create a subfolder named theme-child

4. open theme-child and create a new file named style.css

5. add the following text to style.css. The most important entry is Template which should be equal to your folder name of your parent theme.

/*
 Theme Name:   Theme child
 Theme URI:    http://example.com/whatever/
 Description:  Twenty Fifteen Child Theme
 Author:       John Doe
 Author URI:   http://example.com
 Template:     theme
 Version:      1.0.0
 License:      GNU General Public License v2 or later
 License URI:  http://www.gnu.org/licenses/gpl-2.0.html
 Tags:         nothing
 Text Domain:  theme-child
*/

6. Create a functions.php in the same folder than style.css and add the following code. This code will import the parent style.css and enqueue the child style.css into your active child theme. You must replace parent-theme by the style name that you find in the style.css file of the parent theme, where wp_enqueue_style( ‘theparentname-style‘, get_stylesheet_uri(), array(), ‘1.0.0’ ); 

There is only one directive like this one, you must copy theparentname-style from your parent theme style.css in the functions.php of your child theme (see below)

<?php
function my_theme_enqueue_styles() {
wp_enqueue_style( 'theparentname-style', get_template_directory_uri() . '/style.css' ); 
wp_enqueue_style( 'child-theme', get_stylesheet_directory_uri() . '/style.css', array( $parent_style ), wp_get_theme()->get('Version') );
}
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );

7. active your child theme in Appearances > themes of your wordpress administration panel.

8. Now you can copy and files from your parent theme in your child theme and modify it. The child file will take precedence over the parent file. Keep into account, the child file should be at the same location than the parent file meaning that you should create subfolders if necessary. If something goes wrong, you can delete a child file and WordPress will use the parent file. If you want to modify the CSS, modify the style.css child file.

Then, learn how to customize your style.css


Related Posts:

  • How to customize style.css of your WP child theme
  • Enfold theme VS Genesis framework comparison
  • Benefits/disadvantages of using the genesis framework
Download our Broken link checker freeware here Buy a license key for the Sitecozy broken link checker

Customer Login

Lost password?

Categories

  • Webmaster advice
  • SEO advice
  • Web hosting
  • SiteCozy link checker KB
  • WordPress theme & plugin reviews
  • All articles
Disclosure: We are a professional review site that receives compensation from the companies whose products we review. We test each product thoroughly and give high marks to only the very best. We are independently owned and the opinions expressed here are our own.

Copyright Sitecozy 2018