Trying to show featured posts in category without duplication
-
Hello,
I am trying to create a category page where up to 3 posts can be ‘featured’ if they are tagged as such. I can get the first part of the posts to work properly. i.e. I can show the featured blog posts without issue.
However, when I have a more than 3 blog posts, the additional posts are not being shown by the second part of the php. I cannot figure out why, as I am sure this php worked before I upgraded to WP 3.7. Any help greatly appreciated.
<?php rewind_posts(); ?> <?php $my_query = new WP_Query($query_string . '&tag=featured&posts_per_page=3'); while ($my_query->have_posts()) : $my_query->the_post(); $do_not_duplicate[] = $post->ID ?> <---- Show 'featured posts here -----> <?php if ($my_query->post_count > 3) { ?> <?php if (have_posts()) : while (have_posts()) : the_post(); if (in_array($post->ID, $do_not_duplicate)) continue; ?> <---- Show other posts if there are more than three in the selection -----> <?php endwhile; else: ?> <?php endif; ?> <?php } ?>
- The topic ‘Trying to show featured posts in category without duplication’ is closed to new replies.