Theme Nisarg’s Child Theme

Theme Nisarg’s Child Theme ?>

You can download Nisarg’s child theme here: nisarg-child

There are a few reasons why you would want to use a Nisarg child theme:

  • If you modify a theme directly and it is updated, then your modifications may be lost. By using a child theme you will ensure that your modifications are preserved.
  • Using a child theme can speed up development time.

How to Create a Child Theme

A child theme consists of at least one directory (the child theme directory) and two files (style.css and functions.php), which you will need to create:

  • The child theme directory
  • style.css
  • functions.php

Steps to create Nisarg Child Theme

  1. Create a directory name “Nisarg-child”, which will be placed in wp-content/themes. Make sure that there are no spaces in your child theme directory name, which may result in errors.
  2. Create your child theme’s stylesheet (style.css). The stylesheet must begin with the following:
    /*
    Theme Name: Nisarg Child
    Theme URI: https://falgunidesai.com/Nisarg
    Description: Nisarg Child Theme
    Author: Falguni Desai
    Author URI: https://falgunidesai.com
    Template: Nisarg
    Version: 1.0.0
    License: GNU General Public License v2 or later
    License URI: http://www.gnu.org/licenses/gpl-2.0.html
    Tags: pink,orange,blue,green,yellow, gray, white,black,light,two-columns, right-sidebar, responsive-layout, theme-options, custom-background, custom-header, custom-colors, custom-menu, featured-images,  post-formats, sticky-post, translation-ready, rtl-language-support,threaded-comments
    Text Domain: nisarg-child
    */
    
  3. The final step is to enqueue the parent and child theme stylesheets. The correct method of enqueuing the parent theme stylesheet is to add a wp_enqueue_scripts action and use wp_enqueue_style() in your child theme’s functions.php. Copy the following code to your Nisarg-child theme’s functions.php file:
    <?php
    function nisarg_enqueue_styles() {$parent_style = 'nisarg-style';
    
    wp_enqueue_style( 'bootstrap', get_template_directory_uri().'/css/bootstrap.css' );
    wp_enqueue_style( 'font-awesome', get_template_directory_uri().'/font-awesome/css/font-awesome.min.css' );
    wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
    
    wp_enqueue_style( 'nisarg-child-style',
    get_stylesheet_directory_uri() . '/style.css',
    array( $parent_style )
    );
    }
    add_action( 'wp_enqueue_scripts', 'nisarg_enqueue_styles' );
    ?>

If you want to change any template file in child theme, your child theme can override any file in the parent theme: simply include a file of the same name in the child theme directory, and it will override the equivalent file in the parent theme directory when your site loads.

For more information on how to create child theme refer to WordPress Codex: https://codex.wordpress.org/Child_Themes

Comments are closed.