Wordpress: Special css for TWO Pages

In my blog i have two sites, that need a special css. For the site "projects" i did this:

 <?php if ( is_page('projects') ) { ?>
     <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/projects.css" type="text/css" media="screen" />
<?php } else { ?>
     <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
<?php } ?>

This works like a charm.. but i also need a special css for the home.. How can i do that..? if i just put:

<?php if( is_home() ) { ?>
     <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/home.css" type="text/css" media="screen" />
<?php } ?>

Above the other code, it will not work..

The whole code i use now is:

<?php if( is_home() ) { ?>
     <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/home.css" type="text/css" media="screen" />
<?php } ?>


        <?php if ( is_page('projects') ) { ?>
         <link rel="stylesheet" href="<?php bloginfo('stylesheet_directory'); ?>/projects.css" type="text/css" media="screen" />
    <?php } else { ?>
         <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
    <?php } ?>

Thanks for your help - and sorry for my english !

Solutions

You should do:

<?php if(is_front_page()) { ?>
       // html code here
      <?php } else if ( is_page('projects')) { ?>
        // html code here 
      <?php } else { ?>
        // html code here
  <?php } ?>
Tags: PHP / Css / Wordpress

Similar questions

Wordpress div class container, is it special in wordpress?
Hiall, could someone please tell me, is the class/element some kind of special class for wordpress??? This div is currently wrapping all the content on my site and I am trying to put html code outside of this div, but no matter what I do it won’t let me and it automatically puts everything inside this div. I’m looking at the file that contains the ...
two different wordpress sites in two different folders
This question has already been asked but I didn't find a solution that works for me. I have my main Wordpress site in a subfolder at domain.com/here2 My other Wordpress site is in another subfolder at domain.com/4t I use permalinks for both. Each one uses its own database. No matter how I modify the .htaccess in /4t I am always redirected to the /h...
Wordpress Advanced Custom Fields display two fields from two different post types in one template
I have two post types. I need to display content from each within the same loop. At the moment, I can call the 'releases' post type to display content, but I also need to call the 'artists' post type to display some content in the same DIV. The below line breaks the page with a ‘Catchable fatal error: Object of class WP_Post could not be converted ...
How to frontend two wordpress sites running through two docker containers using nginx.
I've two wordpress instances each running as one docker container. I would like to frontend / proxy these two wordpress instances through a single nginx server. Following is my nginx config file.
Wordpress wp_query get two last inserted posts from two categories in one query
I use the code below to make a query in Wordpress and get two last inserted posts from one category. I have to make two queries one for each category to get the results i need. Is it possible in one query to get the two last inserted posts from two categories? Total results of posts four, two from one category and two from the other, one query. Any...
How to add two widget of two custom post type in Wordpress
hi i need to registry two widget of two post type. the first type is movies and the second is news i have add the widget to function but is showing just one widget of them. i have create two classes and when i test only one of theme its working good ? but when i add it together i see only one of them this is my code class Movies_Recent_Posts extend...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.