• Trying to use the enqueue styles instead of the @import and am having a couple problems.

    The child theme css is loading – BUT SO IS THE PARENT THEME. I believe the Parent theme is loading AFTER the child theme because when I look at “inspect element” in Google Chrome – it shows the div twice – one with my child theme modifications in it – and then one with the original parent theme CSS (which is overwriting my changes)

    Here is the php in the child theme functions file:

    <?php

    add_action( ‘wp_enqueue_scripts’, ‘theme_enqueue_styles’ );
    function theme_enqueue_styles() {
    wp_enqueue_style( ‘parent-style’, get_template_directory_uri() . ‘/style.css’ );
    wp_enqueue_style( ‘child-style’, get_stylesheet_uri(), array( ‘parent-style’ ) );
    }

    ?>

    What am I doing wrong? (sorry – pretty much a Noob & php)

Viewing 6 replies - 1 through 6 (of 6 total)
  • Does it work correctly if you remove the line:

    wp_enqueue_style( 'child-style', get_stylesheet_uri(), array( 'parent-style' ) );

    If not, can you post a link to your site?

    Thread Starter Muskrat37

    (@muskrat37)

    That does not work…

    Site is https://www.orphansafrica.org

    Thread Starter Muskrat37

    (@muskrat37)

    FYI – the specific DIV I have edited is the “#promoImage” div… I have removed the “padding-bottom:339px” and the “background” elements from the child theme css… you can see that the child theme is loading my css without these elements – but then right after the theme loads the parent themes css and replaces these deleted elements but leaves all the other elements that I did not touch.

    It’s like wordpress is comparing the 2 – and picking from each other what is missing from the other… (that’s confusing to write). ??

    Your child theme’s stylesheet is loading twice, but other than that it appears to be working correctly. Can you post an example of a CSS rule that isn’t working correctly?

    Ah, I hadn’t seen your most recent post yet. When you commented out padding-bottom: 339px from your child theme, that doesn’t completely remove it because an identical rule exists in the parent theme. Instead, you need to override the parent theme by setting a different value: padding-bottom: 0;.

    Thread Starter Muskrat37

    (@muskrat37)

    Doh!

    Feeling like a dunce. Quite possible I’ve been staring at these monitors too long today! ??

    Thanks for your help.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘wp_enqueue_styles not working’ is closed to new replies.