1

My WordPress site uses a theme that is a child of a parent theme. As required, both themes have style.css files. However, as far as I can tell WordPress only provides the mechanism to load the child theme style.css file. How do the parent theme styles get loaded? Is it necessary to manually import the parent theme's style.css file into the child style.css file?

0

At the top of your child themes style.css add:

@import url("../twentyeleven/style.css");

Obviously replace twentyeleven with your parent themes folder.

2016 - This practice has now been replaced by declaring the 'Template' in your theme stylesheet header:

Template:     twentyfifteen

https://codex.wordpress.org/Child_Themes

  • OK- what I thought, just wanted to make sure that's the only way.. - thanks – Yarin Sep 13 '11 at 18:58
  • 1
    "using @import: this is no longer best practice." - see codex.wordpress.org/Child_Themes – Tara Mar 19 '15 at 17:48
  • 1
    So you came back 3 1/2 years to downvote it? In September 2011 it was the expected way to build child themes for WordPress. – Alex Older Mar 24 '15 at 13:58
  • 1
    @AlexOlder StackExchange isnt just here to help an individual in the moment they post their question. It is for all people over the course of years. It is common and encouraged to keep answers up-to-date, or to add a disclaimer that the answer is no longer relevant. If someone comes to this page expecting to learn the best <insert current year> way to add the parent's CSS (as indeed, I did), your answer would be misleading. meta.stackexchange.com/questions/11705/… – Jeff Sep 15 '16 at 19:15
1

In functions.php also load parent theme

add_action( 'wp_enqueue_scripts', 'theme_enqueue_styles' );

function theme_enqueue_styles() 
{
    wp_enqueue_style( 'parent-style', get_template_directory_uri() . '/style.css' );
}
-2

You can call the parent css as a separate file in your theme header.php Something like

<link href="<?php echo get_stylesheet_directory_uri(); ?>/css/css.css" rel="stylesheet">

Depending on various factors it may be better to copy and paste the parent css into your child css file, and thus no need to import it at all. Saves http requests etc.

  • this works & thus answers the question. If you dont like the application you could explain in a comment – Jon Aug 11 '15 at 6:31

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.