Categories

Saturday, April 20, 2024
#919814419350 therichposts@gmail.com
Wordpress HooksWordpress Tricks

How to make child theme in wordpress?

How to add custom meta title and meta description in Wordpress?

How to make child theme in wordpress

Hello, welcome to therichpost.com. In this post, I will tell you How to make child theme in wordpress? WordPress is the best cms. Child-theme in wordpress plays very important role. I personally advice always to make and code in child theme because wordpress theme’s need to update everytime and if we will do code in wordpress theme and if theme will be update then we will lose our all the code so in this situation we can make child theme and do code in child theme and save our code with this.

In WordPress Child-Theme, folder you have to make functions.php file and style.css file:

Here are child-theme folder and files:

Theme’s folder structure:

Child-theme’s files structure:

Here is the code to add in child-theme style.css file:

/*
Theme Name: Storefrond child
Template: storefront
Author: Therichpost
*/

After adding the style.css code, you need to activate child-theme in wordpress dashboard themes page:

There are lots of code related to child-theme for accessing the files and that code will be do in child-theme functions.php file and I will tell that code in future posts.

therichpost
the authortherichpost
Hello to all. Welcome to therichpost.com. Myself Ajay Malhotra and I am freelance full stack developer. I love coding. I know WordPress, Core php, Angularjs, Angular 14, Angular 15, Angular 16, Angular 17, Bootstrap 5, Nodejs, Laravel, Codeigniter, Shopify, Squarespace, jQuery, Google Map Api, Vuejs, Reactjs, Big commerce etc.

2 Comments

    • To access Main theme files in child theme you can use below code in child theme’s functions.php file:

      $parent_style = ‘history-stylesheet’;

      // Enqueue Parent theme’s stylesheet.
      wp_enqueue_style( $parent_style, get_template_directory_uri() . ‘/style.css’ );

      // Enqueue Child theme’s stylesheet.
      // Setting ‘parent-style’ as a dependency will ensure that the child theme stylesheet loads after it.
      wp_enqueue_style( ‘child-style’, get_stylesheet_directory_uri() . ‘/style.css’, array( $parent_style ) );

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.