treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[SOLVED]Having a different css style sheet in the Wordpress homepage?

  • How do you tell Wordpress that you want a different css style sheet on the homepage?
  • In the header, add this:

    <?php
    if (is_home()) {
    echo '<link rel="stylesheet" href="homepage.css" type="text/css" media="screen" />';
    }
    ?>
  • Or, instead of adding a whole new CSS file, you can just target the home page in your style.css with a class that you can put on the body.
    <body <?php body_class(); ?>>
  • Expanding on Senff's code, you might actually be looking for this:

    <?php
    if (is_front_page()) {
    echo '<link rel="stylesheet" href="/wp-content/themes/YOURTHEMEFOLDERNAME/homepage.css" type="text/css" media="screen" />';
    } else { <link rel="stylesheet" type="text/css" href="<?php bloginfo('stylesheet_url'); ?>" media="screen" /> }
    ?>
  • That'll totally remove the default style sheet from the homepage. TheDoc's solution is probably more preferable though, as it's unlikely you won't want to use the styles defined in your main stylesheet, but your case may be an exception.