wp_enqueue_style for child theme not working
-
I have created a child theme based on Twenty Sixteen. I have the following code in my child theme functions.php file:
<?php function my_theme_enqueue_styles() { $parent_style = 'parent-style'; // This is 'twentysixteen-style' for the Twenty Sixteen 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') ); } add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' ); ?>
(Cut and paste from the Codex). I have tried with this code, and also substituting the name of the child theme (let’s call it baby for now) as both baby and baby-style, as well as the above code. The child theme changes are not being picked up; its not seeing the child style sheet.
I’m developing on WAMP localhost; I’ve used @import for child themes before without issues and this is the first time with enqueing styles via functions.php. What am I doing wrong? I have searched and googled, and I am just getting more confused. Do I use the generic child-style or put in the actual name of my style?
I changed the background of the child theme to a neon green just to be sure if it was picked up or not, and it “flashes” the green background as the page loads, and then it’s gone, replaced by twentysixteen. I also have a header.php and footer.php file in the child folder and they are being picked up, but style.css is not.
- The topic ‘wp_enqueue_style for child theme not working’ is closed to new replies.