Bootstrap Templates Bundle

Thursday, February 28, 2013

alternate-single-post-template-for-specific-categories


Paste this below code into single.php file and create post-single.php and post-custom.php

<?php
        if ( have_posts() ) { the_post(); rewind_posts(); }
        if ( in_category(1) || in_category(2) || in_category (3) ) {
            include(TEMPLATEPATH . '/post-single.php');
        }
        else {
            include(TEMPLATEPATH . '/post-custom.php');
        }
    ?>


or



<?php
  $post = $wp_query->post;
  if (in_category('portfolio')) {
      include(TEMPLATEPATH.'/single_portfolio.php');
  } elseif (in_category('news')) {
      include(TEMPLATEPATH.'/single_news.php');
  } elseif(in_category('wordpress')) {
      include(TEMPLATEPATH.'/single_wordpress.php');
  }
  else{
      include(TEMPLATEPATH.'/single_default.php');
  }
?>

No comments:

Post a Comment

Wokiee React eCommerce Template