Support » Fixing WordPress » Multiple loop question

  • I would like to have 4 posts on my front page: Feature, Photo of the week and two other most recent posts that aren’t those categories.

    get_posts() works perfectly for the first two. Then when I run through the loop for the 2 most recent, I want to exclude any past photos of the week or features. Unfortunately, the setting for “number of posts to display” makes this a problem. How do I write the third loop to show 2 most recent posts that are not categorized by “Photo” or “Feature” and also aren’t the two posts above. If the 2 most recent posts are the current feature and the photo, then nothing shows with “number of posts to display = 2”.

    Right now I am saving the post number of the photo and feature and skipping those. If in_category() hits one of those, then it counts that as one of the posts to display. That is what I don’t want.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Ok, found this/ . However, it still suffers from the aforementioned problem: in the if statement, the post is counted as displayed. So if the two most recent posts are “Photo” and “Feature” the loop to display the two most recent will not display a thing.

    Ok, you cannot exclude 2 categories with query posts, and you cannot avoid my problem above with a plugin like Category Visibility or any other hack that I could find. Here is my horrible, horrible solution:

    <?php query_posts('cat=1,2,3,4,5,6,7,8,9,10,11,12,13,14,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40'); ?>

    Note that 15 and 16 are missing.

    Hopefully my client will never have more than 40 categories.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Multiple loop question’ is closed to new replies.