How to display multiple single page templates based on categories for WordPress?

I am using multiple stylesheets and need the pages to differ based on category.

I added the following to my header.php, but shows base theme`s single entry template. Any ideas?

Read More
   <?php if (is_category('20')) { ?>
      <link rel="stylesheet" type="text/css" href="wp-content/themes/tanzaku/style.css" />
   <?php } else {?>
      <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_url'); ?>/style.css" />
   <?php } ?>

I am using the same theme as these sites, but I use two themes on my site compared to these.

  1. http://marioortega.net/
  2. http://atelier6.co.uk/

When you click one of the thumbnails, the single ends up on top and the thumbnails at the bottom.

Related posts

Leave a Reply

2 comments

  1. All:

    Thank you for looking into this. In order for me to get this to work, the problem was actually multiple single.php files. This can be solved by having your single.php look like this,

    <?php
      $post = $wp_query->post;
    
      if ( in_category('20') ) {
      include(TEMPLATEPATH . '/single1.php');
    
      } else {
      include(TEMPLATEPATH . '/single2.php');
    
      }
    ?>
    

    I have also edited the question for other people looking for this answer.

  2. Shouldn’t you be using echo statement to put the link into your page.

    <?php
       if (is_category('20')) {
         echo '&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;wp-content/themes/tanzaku/style.css&quot; /&gt;';
        } 
     else {
         echo '&lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;'.bloginfo('template_url').'/style.css&quot; /&gt;';
     } 
    ?>