Specific css on homepage, different one for other pages

Is there a way to have specific css on the homepage and use a different one for all the other pages?

Related posts

Leave a Reply

2 comments

  1. Yes there is. You can add this to your themes header.

    <?php
      if(is_home()){
        // we are on the home page
        echo '<link rel="stylesheet" src="your_stylesheet" />';
      }
    ?>
    

    You can also use other conditional tags to find out if you are on nearly every type of WordPress page. Conditional Tags

    Following on from the comments below, this would be better used like this

    <?php
      if(is_home()){
        // we are on the home page
        echo '<link rel="stylesheet" src="your_home_stylesheet" />';
      }else {
        echo '<link rel="stylesheet" src="your_default_stylesheet" />';
      }
    ?>
    
  2. If you look at the source code on a WordPress page the body class changes for each page mine shows home so i would create my css with this

    body.home #whatever div or body.home .whatever class
    

    Look At The Body Tag