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

  1. joaoramos
    Posted 4 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. Michael
    Part-Time Forum Moderator
    Posted 4 years ago #


    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
    Posted 4 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