Robert
  • 0

How to Create a WordPress Child Theme?

  • 0

Explain simple way to create a child theme without using plugins.

1 Answer

  1. This answer was edited.

    To create a child them in WordPress, do these steps

    1. Create a new folder in the “wp-content/themes” directory and name it as “parent-theme-child”. (You can give any unique name)
    2. Create a new stylesheet (style.css) within the new folder.
    3. In the stylesheet, add the following header information at the top:
      /*
      Theme Name: My Child Theme
      Theme URI: https://example.com/my-child-theme/
      Description: A child theme of the parent theme
      Author: Your Name
      Author URI: https://example.com/
      Template: parent-theme-folder-name
      Version: 1.0.0
      */
      
    4. (Optional) Create a new functions.php file in the child theme folder to add custom functionality. Add following code to enqueue stylesheet.
      function my_child_theme_styles()
      {
          $parent_style = 'parent-theme-style-handle';
          wp_enqueue_style('my-child-style', get_stylesheet_uri(), array($parent_style), wp_get_theme()->get('Version'));
      }
      add_action('wp_enqueue_scripts', 'my_child_theme_styles');
      
    5. Activate the child theme in the WordPress admin area under Appearance > Themes.

     

Leave an answer

You must login to add an answer.