How to create Child theme in WordPress.

Create a new directory(folder) in wp-content/themes after that
inside its own folder, create two files inside it style sheet and a functions.php file Like any theme.

A best practice is to give your theme’s folder the same name as the parent theme and append it with -child. Because we are using the Twenty Fifteen theme, we will call our folder twentyfifteen-child.

Now open you style.css file which you created in the your new child theme folder and Past code in your style.css

/*

Theme Name: Twenty Fifteen Child

Theme URI: http://example.com/twenty-fifteen-child/

description: >- Twenty Fifteen Child Theme

Author: Robin Doe

Author URI: http://example.com

Template: twentyfifteen

Version: 1.0.0

License: GNU General Public License v2 or later

License URI: http://www.gnu.org/licenses/gpl-2.0.html

Tags: light, dark, two-columns, right-sidebar, responsive-layout, accessibility-ready

Text Domain: twenty-fifteen-child

*/
  • Theme name. This is the name that will show up for your theme in the WordPress back end.
  • Theme URI. This points to the website or demonstration page of the theme at hand. This or the author’s URI must be present in order for the theme to be accepted into the WordPress directory.
  • Description. This description of your theme will show up in the theme menu when you click on “Theme Details.”
  • Author. This is the author’s name — that’s you, in this case.
  • Author URI. You can put your website’s address here if you want.
  • Template. This part is crucial. Here goes the name of the parent theme, meaning its folder name. Be aware that it is case-sensitive, and if you don’t put in the right information, you will receive an error message, so double-check!
  • Version. This displays the version of your child theme. Usually, you would start with 1.0.
  • License. This is the license of your child theme. WordPress themes in the directory are usually released under a GPL license; you should stick with the same license as your parent theme.
  • License URI. This is the address where your theme’s license is explained. Again, stick with what your parent theme says.
  • Tags. The tags help others find your theme in the WordPress directory. Thus, if you include some, make sure they are relevant.
  • Text domain. This part is used for internationalization and to make themes translatable. This should fit the “slug” of your theme.

Here is what each line means:

After Completing the style.css you go to “Appearance” → “Themes” in the WordPress back end and find your child theme there. Click on the button that says “Activate.”

And view you theme after activate you can style according to your need in your style.css file.

FUNCTIONS.PHP IN Child Theme Folder

The functions.php file allows you to change and add functionality and features to a WordPress website. It may contain both PHP and native WordPress functions. Plus, you are free to create your own functions.

<?php
//* Code goes here

INHERIT PARENT STYLES IN FUNCTIONS.PHP(CHILD THEME)

Just add code

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

Leave a Comment

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