I started this one expecting this to be easy but have now wasted a huge amount of time with chatGPT trying to find a solution - but the simple scenario is that I have a query loop (of hotels) attached to a Bricks single page template. The query loops works great (and just happens to feed a Bricks Pro Slider) display element. The problem is that on certain pages there are ‘No Results’ for the page, for example one of the region pages simply does not have any hotels in it and so there are no results to show and so a ‘No results’ or similar message needs generating.
If chatGPT is right, that’s an expected behaviour (for some reason) and my empty query loop is just a space on the page and the ‘no results’ text (or bricks’ section template) isn’t called (shown on the page). How can that be right? Is not actually one of the use-cases for the ‘No results’ behaviour?
More detail, there are several more query loops on the page and chatGPT has suggested these should all be set to ‘disable query merge’ and at least one other query on one particular page (via the Bricks template) will also be ‘empty’ by design (until more hotels are added for that particular page/region (and template) - if that all makes sense.
chatGPT was also trying to get me to use an old (if it ever existed) Conditions → Query → Has Posts → FALSE to show/hide a separate div if the query was actually empty (based on the concept explained by chatGPT that “Bricks only triggers the No Results state when the loop actually resolves to an empty dataset. If the loop is being merged, overridden, or not the main query, Bricks never reaches that state — so the fallback never renders.“ - if that’s true?
And so the question remains, “How to show ‘No Results’ text (or template) when a Bricks Query Loop is Empty?“ or by other means dynamically indicate there are ‘no results’ to show? Please put me out of my misery! 
Forget ChatGBT and just read the Bricks docs – you can do that right within the query loop options at the bottom.
Thanks Shingen but that doesn’t work if the query loop itself has no data hence the comment “Bricks only triggers the No Results state when the loop actually resolves to an empty dataset. If the loop is being merged, overridden, or not the main query, Bricks never reaches that state — so the fallback never renders.“ IE that’s the problem, not the solution.
IE neither the ‘no results’ template or text behaviours work, I’ve found if there is ‘no data’ or some other reason that’s preventing the built-in ‘no results’ behaviours from working.
Anyone else come across this?
I do not know what you setup is, but it all works for me. See my screenshots. You can see I have a query on Posts and specifically to a taxonomy of Four (there being zero posts in that category). Then I add text to display as there is no entry and it outputs correctly.
Many thanks for the follow-up. Much appreciated and ‘yes’ I totally agree how it should work and great to see that yours does. I just need to find out what in my page/template set-up is stopping that working in my case. I’ve dropped a direct note to the devs too so see if they can shed any light on it. cheers
Q.
Mystery solved (or mostly solved), if anyone is interested I can post a fuller update when I have more time but my problem resided in the current behaviour of the otherwise excellent Pro Slider (from BricksExtras) in that it’s default current behaviour is to hide the whole container (including the ‘no results’ output content) if there are no results in the query! I have pointed out the team there that is a counter-intuitive behaviour for a ‘no results’ mechanism, but is the reason why I couldn’t see them!
Thanks to Jenn for assisting with this and to David at BricksExtra though who pointed out a good workround (that chatgpt was hinting at) which is that Bricks (since 1.9.x) does support a custom function {query_results_count:bricksid} that can be used with Bricks Conditions in the form {query_results_count:hmvylb} > 0 (where hmvylb is the bricks ID).
That’s covered here :
And in case anyone is/was wandering ‘why use BricksExtras Pro Slider’ anyway?’ the answer is that until Bricks 2.2.x, Bricks’ native filters didn’t work with Bricks Nestable Sliders (which was a long-term glitch/bug bear) - but was very well handled by BricksExtras’ Pro Slider until I realised the issue with the ‘no results’ behaviours).
The test site in question is way too large and the GTM tracking already created for it using custom GTM classes is also way too large and complex so we’re planning on using the suggested {query_results_count:bricksid} < 1 Condition to show a custom ‘no results’ container until any fix is implemented by the BricksExtras team for this.
Q.
1 Like