Monday, 26 August 2013

Displaying just one post from each category on archive page

Displaying just one post from each category on archive page

My categories look like this. Each has one or more posts
-Main Category
--Main Category Sub-category 1
--- 1 post here
--- 1 post here
--Main Category Sub-category 2
--- 1 post here
--- 1 post here
--- 1 post here
--Main Category Sub-category 3
--- 1 post here
When viewing Main Category archive page I only want the first post from
each of the subcategories. So in my case I would only have 3 posts. Using
twentythirteen theme. Don't want to change too much. I hope it can be done
with query_posts.
<?php /* The loop */ ?>
<?php query_posts($query_string . '&??????'); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content-category', get_post_format()
); ?>
<?php endwhile; ?>

No comments:

Post a Comment