WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I register styles in function.php with

function my_scripts() {
    wp_deregister_style( 'header' );
    wp_register_style( 'header', get_template_directory_uri() . '/css/header.css' );
    wp_enqueue_style( 'header' );
add_action( 'wp_enqueue_scripts', 'my_style_sheets' );

I'd like to use different header style sheet for the same header.php file used on another page. How do I do that?

In general, how do I use styles differentiated by template instead of using a global setting like the one above?

share|improve this question
up vote 0 down vote accepted

Create a primary stylesheet and enqueue as normal. Then, make a series of conditional statements using WP core functions - is_home(), is_404(), is_page_template('template.php') and so on. In each of those conditionals, enqueue the stylesheet you want that overwrites your core stylesheet, using your primary (style.css) stylesheet as a dependency.

Untested code, but should work:

function my_styles() {
    wp_deregister_style( 'header' );
    wp_register_style( 'style', get_template_directory_uri() . '/css/style.css' );
    wp_enqueue_style( 'style' );
    if (is_home()) { wp_enqueue_style('homestyle', get_template_directory_uri(). '/css/homestyle.css', 'style'); }
add_action('wp_print_styles', 'my_styles');
share|improve this answer
Thank you. I also found these pages useful: Function Reference/body class, Contextually changing your theme’s stylesheet – seron Jun 7 '12 at 10:43

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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