Query Loop: exclude posts present on the page in other queries loops

Hi brains, I’ve searched everywhere but couldn’t find a way to configure a query loop to exclude from the results posts already present in another query loop on the same page. I am unfortunately not able to code with the query editor and also have tried various ways to add a condition, but have failed.
I will add an image that helps explain what is going on: I basically have a container with two blocks containing the same queryloop. In the first block I present only 1 result (sticky post), with customised graphics, while in the other block I present all the results, in a list, but I would like to exclude the result of the other query from this list.
I am definitely drowning in a glass of water, the solution will be trivial, but I am so hoping someone can give me some hints to solve my crossword…
kind regards, Luca

just use offset ?

you can use exclude but you cant do it dynamically.

for advanced offset or exclude use query editor;
image

or instead of making wordpress sticky create a acf field featured checkbox something and you can filter your loop with that :wink:

there is like 10 different ways to solve this.

Thank you, sinanisler, I’m glad to know (but I was sure) that there are at least ten ways to do this, but none within my reach… otherwise I would not have involved the forum: offset is no good, because the post in the left block has to be sticky, for the editor’s needs, while for the query I’m not up to it.
I’m a bit amazed that such a practical and frequently (I think) need was not included in the UI as feature, while I can either exclude posts manually (whereas I see no utility in being able to exclude posts manually in a dynamic query) or activate ‘exclude current post’ which only makes sense on the single post template… I thought about using a condition, but I don’t know how to formulate it…

Does anyone else have a simple, solving solution to give?

Update: I did it! I solved it with query editor, which I was a bit apprehensive about, not being a programmer. In the query of the first block I forced the presence of stickies, while in the second I forced their absence and no longer have duplicates :muscle:.

I’ll add the code I used (superbanal) in case there’s some other klutz like me who doesn’t know which way to turn, or if anyone has even better proposals… Love Bricks!

block 1

return [
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘posts_per_page’ => -1,
‘category_name’ => ‘rules’,
‘post__in’ => get_option( ‘sticky_posts’ ),
];

block 2

return [
‘post_type’ => ‘post’,
‘post_status’ => ‘publish’,
‘posts_per_page’ => -1,
‘category_name’ => ‘rules’,
‘post__not_in’ => get_option( ‘sticky_posts’ ),
];

2 Likes