Exclude duplicate posts on multiple query loops

I saw this post that is very similar to my question, but there is no answer:

I’ve created two blocks to be used at the bottom of single posts, one to show related posts and one to show latest posts. But I’m getting duplicate posts in these. Any way to prevent the duplicates?

Example: Help Us Beta Test Our Own Fantasy Golf System -- for FREE!

Thank you!

Support provided a slick idea to this problem that works pretty well for what I was trying to accomplish, setting query loops for Related Posts and Latest News on each post.

First, set the dynamic Related Posts block for all the Categories you want shown on a post.

Then in the Latest News block, in the container that holds the query loop, add a parameter to Exclude Taxonomies by Category, then under Select Terms exclude ‘Current Post Terms’.

That will prevent the duplication, since it’s blocking the category of the current post in Latest News.

Clever and clean.

2 Likes

Neat solution. Thanks for sharing it.

It still doesn’t solve for what you asked about, Dan, having multiple blocks of different Categories on the same page with no duplications.

That process is doable in WP, as I’ve used other themes with that functionality. If someone can solve for that, I have a use for it…

For example detail to my above statement, I previously used a magazine theme called Presso that allowed me to create a custom page with a featured post at the top, a Latest News section with a dozen posts of mixed categories following that, then 6 different Category blocks of one story each below that, all on the same page. Then I could check a box on that page titled ‘Prevent Duplicate Posts’.

If someone at Generate Blocks would like a copy of that theme to see the magic underlying that checkbox, I’m happy to supply it…