I’ve trying for hours, also checked various threads about nested query loops on this forum (but none has been solved) and asked ChatGPT 3 different times about this. To me the solution to this is indeed not obvious, and I hope Bricks team could prepare a proper tutorial on how to use nested query loops. It seems there’s many more people struggling with this.
This is my use case:
On this page about public biddings as you can see there are 4 main groups (mainly years, so there will be more in the future). Inside each there’s a tab element with as many tabs as “estates” (open, under review, solved/closed). Year 2025 has 3 estates, but ‘24 and ‘23 only one. Finally, inside each tab/estate there’s a list of the public biddings which correspond to that group and estate. So the query loop of the list of biddings is inside two other loops, which should work as filters.
I would like the content on this page to load automatically, based on the existing groups, estates and biddings. So I don’t want to manually edit the tabs or add new groups when new years come.
Is there someone who could help me build this structure? It would be really appreciated 
Hi there,
This can’t be achieved natively in the builder.
But you can use hooks to create a custom loop for that. Unfortunately, we don’t have any example code for that.
This is a rough idea for you:
- Create a custom loop that can retrieve all years available from your post type
Might need a custom query like:
global $wpdb;
$years = $wpdb->get_col( "SELECT DISTINCT YEAR(post_date) FROM {$wpdb->posts} WHERE post_status = 'publish' ORDER BY post_date DESC" );
return $years; // Return an array of years
- Create a nested post loop, which is going to perform a post query that will performa date_query based on the year loop in step 1.
Similar tutorial (By Brickslabs some of them are paid version)
How to create a custom loop
Hope this helps.
Regards,
Jenn
1 Like
Thank you very much Jenn for your reply! 
Excuse me for the delay, I was travelling these last two days.
It’s good to know it’s not possible. It’s a pity it can’t be achieved in the builder but at least now I know it’s not because I didn’t how to make it work in the builder.
Alright, I’ll check the tutorials and custom query you shared and will try to make it work.
Thanks again for your help!