Adult Talk About Child Theme

Adult Talk About Child Theme

Have you ever faced a problem with saving your modifications while updating the theme? Oh, that is the most unpleasant thing that can happen to you when all your work goes down the drain in seconds! Today I will tell you how to get rid of this headache with just a few steps.

What is it? How does it work? Why do I really need this? All these questions are very reasonable if you have never heard about that.

What is a Child Theme in WordPress?

Child theme is a must-have for any WordPress theme.It is a theme which saves all the capabilities of a parent theme and even design features , but has its own files that won't be edited with the next parent theme update.

Have a look at the major benefits of creating a child theme:

  • using a child theme you can adjust theme option to your needs
  • your theme editings will be never lost
  • the original source code of the parent theme is not changed so you can always roll back your changes
  • and etc.

That's why I recommend you to pay a couple of minutes to create a child theme for your current one. Let's do it together!

Child Theme Creation

To begin with this easy instruction you have to open the directory with all your themes on a server and find the name of your current theme ( lets call it 'parent' ).

The first step is to create a new folder in the .../wp-content/themes/ directory and call it the same name, but add '-child' suffix to the end of the name.

So if your parent theme name is 'retropress', so a new child theme will be called 'retropress-child'. That's it. You have done it, but to make it work you have to breath a new life into this theme.

The second step is to create a couple of files: style.css and functions.php inside the theme folder. These are the only obligatory files that must be there. All the rest are optional.

These two files must be completely empty in the begining and the third, actually the last step, is to add a few lines to each of them.

Style.css file must be started with the following header code:

/*

Theme Name: Gameday Child
Theme URI: https://smthemes.com/gameday/
Author: The Smart Magazine Themes
Author URI: https://smthemes.com/
Template:  gameday
Description: Template by SMThemes.com
Version: 3.0
License: Creative Commons 3.0
Theme date: 11/12/2012
License URI: license.txt

*/

It has a slight differ from a parent stylesheet - look at the screenshot below:

This difference is the name of the theme, you would better change it to help yourself find your child theme on the Appearance --> Themes screen in the dashboard of WordPress and the line 'Template:gameday'.

You can name your theme with any word, but the template must point to the parent theme. In my case it was the 'gameday' theme, but your will have to specify your parent theme name. That's extremely important.

Functions.php file must conclude the style.css file of a child theme, so it has to contain the folloing code:

<?php
function my_theme_enqueue_styles() {

    $parent_style = 'parent-style'; // This is 'gameday-style' for the GameDay theme.

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

Now you may start to work with your child theme and add any additional styles you want by simply editing a newly created style.css file.

As well as you have created style.css file and then included it with the use of functions.php file you may create any new file like footer.php,for instanse. Now you may simply create any new theme template like content-page.php, but your parent theme will be saved as it is.

The best idea is to start building a site with creating a child theme to speed up the process from the beginning.

6 years ago
Hello guys, You can buy Sex Toys here at http://www.love365.ph our store is located in Makati Ave. In Front of A-venue Mall. The Philippine Leading Sex Toys Store.

Leave a Reply