Why does my child theme CSS get called twice?

This post is linked from this post which I have now updated with the changes in this post

Thank you for bringing up this issue. I have quickly tested the scenario and the child style is actually loaded twice.

When I updated the codex a while ago I made sure that the child style would be loaded after the parent style, never actually taking into account that this is actually done by default and the code given would actually load the child stylesheet twice.

This can be easily rectified by simply removing the $priority from the function and removing the enqueue part for the child theme. I have retested everything, and it works. It would be nice if a couple of people can collaborate this.

In the mean time, I will update the codex and link to this post.

Here is the working code

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

EDIT

For anyone that this post is not working for, please see this post. You will need to go and look on how the parent theme is adding the styles. The code in this question strictly believes that the styles in the parent are loaded in the correct way that they should be. If not, look at the alternatives in the linked answer and try those out

Leave a Comment