How to create a Child theme in WordPress

A child theme allow you to make modifications to your theme and add functions to your website without affecting the parent theme. You can then perform updates on the parent theme and it won’t affect your modifications. It is really easy to create a child theme. You only need to create a folder with 2 files in it: style.css and functions.php.

Template to Download

We provide you a child theme template you can download: 
WordPress Child Theme Template

Upload the zip file through the WordPress dashboard:

  1. Appearance → Themes → Add New or go to this link: mydomain.com/wp-admin/theme-install.php
  2. Upload ThemeChoose FileInstall Now

Then edit the CSS file using either your FTP client, the File Manager from your cPanel of your hosting or the File Editor from your WordPress dashboard (and disable this function afterwards).

Content of the child theme template

Here is the content of the files (if you prefer to create your own) and how to edit it to link it to your selected parent theme.

Folder

Name: theme-child

Replace “theme” for your parent theme name: parentthemename-child

* Please note this step has no effect on the functionality of the child theme but is useful for you.

style.css

/*
Theme Name: Theme Child
Template: themefoldername
*/

/* write custom css */

Replace text

  • Theme Name: Theme → Enter the name of the parent theme
  • Template: themefoldername → Enter the name of the folder of the parent theme (check using your FTP software, the File Manager function of your hosting cPanel or the File Editor in WordPress Dashboard if you haven’t disabled it)

You can enter additional parameters but those are the only required ones.

functions.php

<?php
function my_theme_enqueue_styles() {

    $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen 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' );
?>

You can later on add additional functions here.

Additional Informations

Interesting WordPress Links

Do you like it?

Last Update: March 5, 2017  

Attachments -

March 5, 2017   36    Website    
Total 0 Votes:
0

Tell us how can we improve this post?

+ = Verify Human or Spambot ?

728x90-_0005_3-free-goods

Launch Websites with Pre-build codes from 2$

Build WordPress Websites with Drag & Drop Themes and Plugins

Reply