Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Catherine Millington
Catherine Millington
3,754 Points

Wordpress: How do I get my new child default.css to load instead of the parent one? (Fifteen theme)

I have made a new default.css having seen that the header background i want to change is in this file. It keeps reloading the old parent file though even though i have made the same file structure in the child theme.

Sue Dough
Sue Dough
35,800 Points

Are you sure you want the child theme to load instead of the parent theme? That means you won't be able to use any CSS from the parent theme. My guess is you want both to load so you can add your changes on top of the parent theme. Have you enqueued the child theme style sheet?

3 Answers

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points

You can use the child theme so long as you link back to the parent theme folder in the CSS file.

Try adding a php file called functions.php to the child theme folder with the following code

<?php 

// Remove WP Version From Styles    
add_filter( 'style_loader_src', 'sdt_remove_ver_css_js', 9999 );
// Remove WP Version From Scripts
add_filter( 'script_loader_src', 'sdt_remove_ver_css_js', 9999 );

// Function to remove version numbers
function sdt_remove_ver_css_js( $src ) {
    if ( strpos( $src, 'ver=' ) )
        $src = remove_query_arg( 'ver', $src );
    return $src;
}

?>
Catherine Millington
Catherine Millington
3,754 Points

Thank you both for your time! I have updated the functions.php and still no luck. I have inspected the element and it is still drawing the parent file but would it do that anyway maybe? I don't know if you're familiar with the fifteen theme. I am trying to change the background of headings and roll-overs from a transparent black and they appear to be in the default.css. I have updated the .less file too. Sorry for the late reply, I'm based in the UK so it got late.

Hi Catherine,

If you're working on a child theme it will usually take the parent theme too, in this case Twenty Fifteen.

You should be able to add a style.css to your child theme and essentially override the parent styles though as the child stylesheet appears below the parent one. The WordPress Codex has great examples for what your child stylesheet should look like to achieve this.

If you are looking to develop your own custom theme. If so, I'd recommend going over the WordPress Theme Development as this goes in to more detail for how to develop them.

Sorry if you know the above already but if not, hope that helps :)

-Rich