Wordpress loop > unique loop renders slightly wrong results...

Posted by Travis Neilson on Stack Overflow See other posts from Stack Overflow or by Travis Neilson
Published on 2009-12-25T09:05:54Z Indexed on 2010/05/10 6:54 UTC
Read the original article Hit count: 296

A few things to understand before my question will make sense:

  • I use a hidden category called 'Unique' to specify if the post will use the single.php or a special one used for the unique ones.
  • I want the index to act as a single: showing only one post, displaying next/prev post links, and comments also.
  • I need the index.php to say if the post is in category 15 (unique) than <the_unique_content>, else; <the_default_content>

My loop does all this, but the problem is that if the current post is unique, it also displays 1 additional post below the unique post.

Here is the loop >

<?php $wp_query->is_single = true; ?>

<?php $post_count = 0; ?>

<?php if (have_posts()) : while (have_posts()) : the_post(); ?>    

    <?php if ($post_count == 0) : ?>

<?php if (in_category('15')) { ?>   

<?php the_content(); ?> 

<?php } else { ?>	



	<?php the_content(); ?>    



    <?php $post_count++; ?>

Thanks for any help!

© Stack Overflow or respective owner

Related posts about Wordpress

Related posts about loops