WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Prevent same post in multiple loops (3 posts)

  1. joaoramos
    Member
    Posted 3 years ago #

    I'm using this on my single.php to retrieve both the similar posts (using the same tags) and the popular posts (using comment count) as well. There is a problem, though. How to prevent similar posts to show up as popular posts too?

  2. alchymyth
    The Sweeper & Moderator
    Posted 3 years ago #

    possibly:
    http://pastebin.com/HTRhygAG

    re 1.
    turn all tag ids into one array;

    re 2.
    use the 'post__not_in' in the second loop, with an array of collected post ids.

  3. joaoramos
    Member
    Posted 3 years ago #

    Ah, dumb me — I completely forgot I could do that using 'post__not_in'. Thank you!

Topic Closed

This topic has been closed to new replies.

About this Topic