0

I have a wordpress theme which I hacked to my specifications. I know I'm not supposed to do that but it was long ago so now I'm trying to implement a child theme and I've put those revisions into the child's style theme. Unfortunately, it loads the parent style theme AFTER the child theme's, so of course, all gets overidden. Here is the code in my functions.php:

add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );
function theme_enqueue_styles() {
    wp_enqueue_style( 'child-style', get_stylesheet_directory_uri() . '/style.css',
        array('parent-style')
    );
}

and here is the way it looks on the rendered code:

<link rel='stylesheet' id='defaultbasic-css'  href='http://www.julia-silverman.com/wp-content/themes/artist-child/style.css?ver=1' type='text/css' media='all' />
<link rel='stylesheet' id='basic-css'  href='http://www.julia-silverman.com/wp-content/themes/artist/css/style.css?ver=1' type='text/css' media='all' />

How do I force it to change the order so my child theme takes precedence? I already tried loading it with priority parameter 11 but that produced the same result.

Note: Currently I've retained the amended styles in the parent theme - I will not remove them (and replace with a clean theme) until I can get the child to work.

1 Answer 1

1

Looking at the id's in your rendered code, the name of your parent style seems to be 'basic-css'. That would mean you need array('basic-css') as the dependency in your wp_enqueue_style.

However, in the code the child style seems to be called 'defaultbasic-css', while you enqueue it as 'child-style'. So it looks like there is some relevant code missing.

1
  • 1
    Please note that , handle is baisc and -css is appended by WordPress while en-queuing.
    – bravokeyl
    Jun 17, 2016 at 9:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.