Alternate single post template for specific categories
-
OK, so I’ve figured out most of this, I think, but I need some help implementing. I want it so when a specific category is posted in, it uses an alternate single post template that I’ve called singlereview.php. So, I went into the codex and found this bit of code and added in my category IDs:
<?php if ( have_posts() ) { the_post(); rewind_posts(); } if ( in_category(25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 38) ) { include(TEMPLATEPATH . '/singlereview.php'); } else { include(TEMPLATEPATH . '/single.php'); } ?>
However, I’m having trouble figuring out where in the single.php to put it and if I have to replace other code with it or what.
This is my single.php:
<?php get_header(); ?> <div id="topbanner_single" class="column span-14"> <!-- start top banner --> </div> <!-- end top banner --> <div id="post_content" class="column span-14"> <!-- start home_content --> <?php if (have_posts()) : ?> <?php while (have_posts()) : the_post(); ?> <div class="column span-11 first"> <div id="post_header"> <div class="post_title" id="post-<?php the_ID(); ?>"><a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a></div> <div class="post_info"> By <?php the_author_posts_link(); ?> <span class="dot">⋅</span> <?php the_time('F j, Y'); ?> <span class="dot">⋅</span> <?php the_category(', '); ?> <strong> </strong><?php edit_post_link('edit','','<strong></strong>'); ?> </div> </div> <div id="post"> <?php the_content('<p>Continue reading this post</p>'); ?> <div id="post_footer"> <div class="post_meta"> <!-- AddThis Button BEGIN --> <a href="https://www.addthis.com/bookmark.php" onclick="window.open('https://www.addthis.com/bookmark.php?wt=nw&pub=Saving Progress&url='+encodeURIComponent(location.href)+'&title='+encodeURIComponent(document.title), 'addthis', 'scrollbars=yes,menubar=no,width=620,height=520,resizable=yes,toolbar=no,location=no,status=no,screenX=200,screenY=100,left=200,top=100'); return false;" title="Bookmark and Share" target="_blank"><img src="https://s9.addthis.com/button1-addthis.gif" class='addthis' width="125" height="16" border="0" alt="Bookmark and Share" /></a> <!-- AddThis Button END --> <span class="dot">⋅</span> <?php if(function_exists('wp_email')) { ?> <?php email_link(); ?> <span class="dot">⋅</span> <?php } ?> <?php if(function_exists('wp_print')) { ?> <?php print_link(); ?><?php } ?> </div> </div> </div> <?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?> <div class="discussion_header"> <div class="comments_for"><?php comments_number('no comments', '1 comment so far', '% comments so far'); ?></div> </div> <div id="comments"> <!-- start comments --> <?php comments_template(); ?> </div> <!-- end comments --> </div> <?php endwhile; else: ?> <p>Lost? Go back to the <a href="<?php echo get_option('home'); ?>/">home page</a>.</p> <?php endif; ?> <?php get_sidebar(); ?> </div> <!-- start home_content --> <?php get_footer(); ?>
Viewing 13 replies - 1 through 13 (of 13 total)
Viewing 13 replies - 1 through 13 (of 13 total)
- The topic ‘Alternate single post template for specific categories’ is closed to new replies.