WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Multiple loops; no duplicates entirely (5 posts)

  1. michaelcollado
    Member
    Posted 2 years ago #

    Hey! I'm building a new homepage loop for a child theme (based off TwentyTen, yes) that's a bit more Magazine-ish. (The site I'm running is a TV review site, just so it can be easier to understand category titles.)

    As such, there are about four areas of posts. The top is just one featured post, below it are two columns with about five different posts, respectively, from separate categories (however these amount to about four loops because it's one image and heading and then four just-headlines), and then a final loop below all of it which is just a standard archive of latest posts.

    My problem is duplicate posts. I want to get rid of them across the board (except maybe the latest posts) but can't figure it out. Using what I found in the codex, if the most recent post is a featured post but also in a category for one of the columnized loops, then it just disappears from the column. That's good, but it doesn't replace it with the next post…which is sort of what I'm looking for. I don't want a blank space!

    I hope some of this makes any sense. Here's a pastebin of my loop code:

    http://pastebin.com/N6C9VRjv

    Any help would be greatly appreciated! (I'm also trying to figure out pagination, but that's for another post!)

  2. alchymyth
    Forum Moderator
    Posted 2 years ago #

    http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action

    particular the section after this headline 'Note for Multiple Posts in the First Category'

    i.e. using an array for $do_not_duplicate and the method with 'post__not_in' parameter in the queries.

  3. michaelcollado
    Member
    Posted 2 years ago #

    Thanks, I implemented the different code for the loops with multiple categories! :) However, my real issue still persists. Is there no way for the loop to access the next post if one is already in use? For example, my final loop should show 8 posts, but since there are already 5 posts showing in other loops before it, it just shows 3. I want it to skip that post that's already shown but still show 8.

  4. alchymyth
    Forum Moderator
    Posted 2 years ago #

    read the lines and examples after this headline 'Note for Multiple Posts in the First Category' within this Codex chapter: http://codex.wordpress.org/The_Loop#Multiple_Loops_in_Action

  5. michaelcollado
    Member
    Posted 2 years ago #

    Thanks alchymyth, I read that document and implemented the codes endlessly but just couldn't get the results I wanted. HOWEVER I DID solve the problem. If anyone has my same issue, you can have a look at how I set up my loop, which is paginated with only the final loop.

    http://pastebin.com/rhLv3rZv

    I forgot where I found it but it saved my life. I really know someone can benefit from it! :)

Topic Closed

This topic has been closed to new replies.

About this Topic