Display latest post, followed by latest from each category (6 posts)

  1. deeve007
    Posted 6 years ago #

    Hi there,

    I want to display a landing page that shows a "feature" article which would be the most recent post from any category, followed by the most resent post from each category (4 categories).

    I can do each of these things separately, but the thing I can't work out is how to check so that for whatever category the main "feature" article is from, it will actually show the second most recent article in the category section below the feature article. So basically the feature article won't be shown twice on the page.

    Hopefully this makes sense.

  2. keighl
    Posted 6 years ago #

    You can use the offset parameter in query_posts()


  3. deeve007
    Posted 6 years ago #

    That works if I'm just showing the 5 most recent posts in order from any category.

    However the first ("feature") item is the first one overall from all categories, but then I am showing a post from each category, with only one of those categories - the same one that contains the "feature" post - "offset". So how do I determine which one?

  4. Michael
    Forum Moderator
    Posted 6 years ago #

    you could get the post ID of the featured post and then exclude it in the following category queries (http://codex.wordpress.org/Template_Tags/query_posts#Post_.26_Page_Parameters):

    <?php $args = array(
    	'post__not_in' => array($featured_post_id)
  5. keighl
    Posted 6 years ago #

    Ahh, I see, the feature post comes from all categories. alchymyth's idea will work.

  6. deeve007
    Posted 6 years ago #

    Cool, that looks like it should do the trick. Once I've had time to try it out and it works I'll then mark this as resolved.


Topic Closed

This topic has been closed to new replies.

About this Topic


No tags yet.