• 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.

Viewing 1 replies (of 1 total)
  • Thread Starter Sue

    (@suelaren)

    Update: Each time I try to edit the stlye.css (via WordPress APpearance editor, so I KNOW it’s grabbing the child theme stylesheet) it does change it, but there seems to be another stylesheet that supercedes those changes.

    Using the developer extension in Chrome, I’m trying to reduce the space on top of the header title and image from 32px to 12px. Here’s what I see after editing my child theme style.css:

    html {
        margin-top: 32px !important;
    }
    html {
        <del>margin-top: 12px !important;</del>
    }
    

    The lined out change I want to make does refer to my localhost/domain/wp-content/themes/mychildtheme/style.css when I hover on the style.css?ver=4.6:13

    The one that’s being seen (for this and other things I’m trying to change, I’m using this as an example) is localhost/domain/:92 it’s (index):92

    So how do I get MY stylesheet to take precedence??

Viewing 1 replies (of 1 total)
  • The topic ‘wp_enqueue_style for child theme not working’ is closed to new replies.