WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. deeve007
    Member
    Posted 4 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
    Member
    Posted 4 years ago #

    You can use the offset parameter in query_posts()

    http://codex.wordpress.org/Template_Tags/query_posts#Offset_Parameter

  3. deeve007
    Member
    Posted 4 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. alchymyth
    The Sweeper & Moderator
    Posted 4 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)
    );
    query_posts($args);
    
      ?>
  5. keighl
    Member
    Posted 4 years ago #

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

  6. deeve007
    Member
    Posted 4 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.

    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.