How to create wordpress child theme?

child theme

Create wordpress child theme

If you want your wordpress website to be upgrade safe, it is always best practice to create a child theme and then do the modifications. Child theme inherits all features from the parent theme.

You can build custom theme by creating a child theme and your changes are not overwritten or your customizations are not lost when there is a theme version upgrade available.

Here are steps to set up a wordpress child theme:

Create child theme folder

Create a folder in wp-content/theme with the themename-child

child theme

twentyfifteen-child

 

Create a style sheet

File  style.css will have code as below. Keep the Template name same as your Parent theme. In this file you can write your css code and customise your parent theme

/*
Theme Name: Twenty Fifteen Child
Theme URI: http://example.com/twenty-fifteen-child/
Twenty Fifteen Child Theme
Author: Manjeet Kaur
Author URI: http://example.com
Template: twentyfifteen
Version: 1.0.0
Text Domain: twenty-fifteen-child
*/

Now Activate your child theme.

Go to Apprearnce and Activate your child theme.

Create functions.php

<?php
add_action( ‘wp_enqueue_scripts’, ‘my_theme_enqueue_styles’ );
function my_theme_enqueue_styles() {

$parent_style = ‘parent-style’;

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’)
);
}

?>

Now you can start writing your own css code in the style.css and php code in functions.php

Feel free to comment below if you have any questions.

 

2 thoughts on “How to create wordpress child theme?”

  1. behavioral interview questions

    I got this website from my pal who informed me regarding this web site and now this time I am
    browsing this website and reading very informative content here.

Leave a Comment

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