0

I am trying to change my @import style.css to wp_enqueue_style for my child themes. I added the following into my functions.php child theme and it returns a 500 error. I looked at this and pretty much followed it to the T. I also looked at this but the answer didn't make sense to me. I am pretty new at this so I just couldn't make the jump.

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

Any help would be good here as I would rather enqueue scripts the faster and better way. I am testing this on my local before activating it live, so I can't give the site URL.

3

I think if you change your wp_enqueue_style to the one below it will work perfectly. This is the way I do it inside my own functions.php file.

function wpse_scripts() {
    // Theme Stylesheet
    wp_enqueue_style('style', get_stylesheet_uri());
}
add_action('wp_enqueue_scripts', 'wpse_scripts');

Although you can do it the way your doing it, it's just you've added a / before your style.css and you don't need that. By adding the / your script is looking for a folder called style.css

function wpse_scripts() {
    // Theme Stylesheet
    wp_enqueue_style('style', get_stylesheet_directory_uri() . 'style.css');
}
add_action('wp_enqueue_scripts', 'wpse_scripts');

The way your doing it would be done like this

Here are some places to start when changing your functions.php in your child theme.

Child Theme

  • Thanks for that. I tried it but it still didn't work. I am using a WPMU site with multiple themes. Would this cause issues? – Ollie Feb 2 '16 at 22:38
  • Have you tried the bottom solution I gave you? If not then I'm not too sure as I've not really done much on WPMU – Stephen Feb 2 '16 at 22:39
  • Yeah, I tried both snippets and neither work. I thought they would as they look pretty standard. Do you think there is a need to identify the exact parent theme I am looking to use as there are several themes in the setup? – Ollie Feb 2 '16 at 22:50
  • You try try identifying the exact parent theme whether it will work or not though I have no idea my friend. Best of luck with this – Stephen Feb 2 '16 at 23:07
  • Some of the child theme functions were messing with the parent functions. Once I removed them your solution worked. – Ollie Feb 3 '16 at 0:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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