Plugin Support
ying
(@yingscarlett)
Hi there,
In that case, what kind of content do you want to output?
Let me know!
Hi Ying,
Perhaps some raw HTML? Or a backup post template block for when there are no posts? But even just some text saying ‘No posts found’ would be fine.
Thanks,
Plugin Support
David
(@diggeddy)
Hi there,
for now you can do something like this:
1. Add this CSS to your site:
.has-no-post-message:not(:empty) + .no-post-message {
display: none;
}
2. Select your Query Loop block, and give it an Advanced > Additional CSS Class(es) of: has-no-post-message
3. Then immediately after the Query Loop Block, add a new block eg. a Container and give it a Class of no-post-message
3.1 Add whatever you want in the no-post-message container. It will only display if the query loop before it empty.
@diggeddy Thanks, that was helpful!
@diggeddy, I don’t see the GenerateBlocks Query Loop block having an Advanced > Additional CSS field. I’m using GenerateBlocks 1.6.0 and GenerateBlocks Pro 1.4.0.
Hi @theframeguy,
Try adding the Query Loop inside a GB Container, then give this Container the has-no-post-message class.
Then, add the no-post-message after the Grid Block of the Query Loop Block.
Example: https://share.getcloudapp.com/6quN5v6J
The code for this would be:
.has-no-post-message .gb-query-loop-wrapper:not(:empty) + .no-post-message {
display: none;
}
Thank you @fernandoazarcon2, that works. Of course, making a message field part of the GB Query Loop block would be the best solution. While working in the editor, the GB Query Loop block does display “No results found” when there are no posts.
You’re welcome, @theframeguy!
Hi there! We haven’t heard back from you for a while now so we’re going to go ahead and set this topic as resolved. Feel free to reply if you need any more help.
Hi, since the Query Loop may output some whitespaces, :empty will not work. Is there another way to introduce content here?
I have noticed that there is a core/query-no-results block. this does the trick π
Just add it inside your loop and add content there.
-
This reply was modified 3 years ago by
bellian.
Glad you found a solution!