• I’m creating a news-style layout with a featured story at the top and three categories of posts at the bottom.

    Here is how I generate these per-category loops at the bottom:

    query_posts( 'cat=3&posts_per_page=4' );

    However, the featured story at the top will always be in one of these categories as well, and I need a way to exclude it from the results lower on the page.

    Two solutions occurred to me:

    1. Create a ‘featured’ category (id=81) for the story at the top, and exclude that post in this manner:

    query_posts( 'cat=3&cat=-81&posts_per_page=4' );

    But this doesn’t work; the second “cat” simply overrides the first one, and it lists all the posts that are not inside the ‘featured’ category.

    2. Retrieve the ID of the featured post higher on the page and then exclude it using something like this:

    query_posts( 'cat=3&p=-108&posts_per_page=4' );

    But this doesn’t work either; it ignores the minus sign and returns only the post ID 108.

    Any suggestions?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Exclude a "featured" post from a per-category loop?’ is closed to new replies.