Reputation: 41
Hello I followed the steps on: https://codex.wordpress.org/Child_Themes
and still no luck, the theme activates fine but the parent theme still remains fully active.
Any help would be much appreciated thank you. Again the child theme does not seem to overwrite the parent theme dalton.
Upvotes: 0
Views: 82
Reputation: 5915
You shouldn't need to enqueue the parent theme's stylesheet in your child theme CSS - that should already be enqueued (and you may find, if you look in the source, that you've simply got two copies of the parent theme stylesheet in place).
Enqueue your child theme stylesheet like so:
add_action('wp_enqueue_scripts', 'my_the_enqueue_styles', 12); // Give this a lower priority so that it should be enqueued after the parent theme
function my_the_enqueue_styles() {
wp_enqueue_style('child-style', get_stylesheet_directory_uri() . '/style.css');
}
...then, in your child theme CSS, add something obvious like:
body {
background-color: purple;
}
...and you should see that the child theme stylesheet is loaded alongside your parent theme elements.
It's worth noting that get_template_directory_uri()
will always refer to the parent theme, whereas get_stylesheet_directory_uri()
will always refer to the currently-active child theme. If there is no child/parent theme and you're using a regular standalone theme, you can use these commands interchangeably.
Upvotes: 1