The Lodge is members-only design/dev videos and Office Hours.

Next Office Hours Session: "Implementing an SVG Icon System" Nov 30 - 6:00 PM Eastern

most recent post from each selected categories

  • cjk
    # May 17, 2009 at 4:56 pm


    I am using the following code on my static home page outside of my wordpress installation. This is working great, I have it set to grab the 3 most current posts (from all categories) from my blog. However, I wonder if anyone can help me figure out how to have it only grab the 1 most current post in each of 3 select categories – still resulting in 3 excerpts but only the most recent from each of 3 select categories.



    The url is:


    # May 17, 2009 at 6:03 pm

    Hi Chris,

    I don’t have a quick answer for you. Here’s some info that may help you figure it out:

    The code you supplied is the WordPress Loop that spits out the content of your posts. The Posts that you display is actually requested earlier.

    You should be able to add an if statement inside the loop like this:

    < ?php if (in_category('3') && is_home() ) continue; ?>

    You’ll have to customize it to look for a variable that is only set if that category has already been filled up… make sense?

    You could probably do three separate "Loops" that only spit out one post, and make sure that post is from a certain category.

    I hope that points you in the right direction.

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

There's a whole bunch of content on CSS-Tricks.

Search for Stuff   •   Browse the Archives

Get the Newsletter ... or get the RSS feed