function of parent not working in childtheme

I have a plugin used on a parent theme which uses shortcode. The plugin (shortcode) works on the parent theme but when I switch to child theme it no longer works. I've only added the child theme code in the child theme function... this is the only script currently in child function.

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

I thought functions like that are inherited from parent. Any advice?

Topic child-theme shortcode plugins Wordpress

Category Web


If your child theme style.css contains actual CSS code (as it normally does), you will need to enqueue it as well. Setting ‘parent-style’ as a dependency will ensure that the child theme stylesheet loads after it. Including the child theme version number ensures that you can bust cache also for the child theme. The complete (recommended) example becomes:

add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );

          function my_theme_enqueue_styles() 
          {

              $parent_style = 'parent-style'; // This is 'twentyfifteen-style' for the Twenty Fifteen theme.

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

           }

where parent-style is the same $handle used in the parent theme when it registers it’s stylesheet. Refer


For inherited parent theme you need to add Template lines in child theme. Please read this https://codex.wordpress.org/Child_Themes

            /*
             Theme Name:   Twenty Fifteen Child
             Theme URI:    http://example.com/twenty-fifteen-child/
             Description:  Twenty Fifteen Child Theme
             Author:       John 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
            */

Here "Template: twentyfifteen" is important to call parent theme. Please check this in your child theme.

Also you can use this plugin to generate child theme. https://wordpress.org/plugins/one-click-child-theme/

I hope this will help you solve your problem.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.