开发者

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?

   <?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 开发者_StackOverflowtheme 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.


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.


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;';
 } 
?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜