Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fallback content for query loop block when there are no posts. #40014

Closed
AdsonCicilioti opened this issue Apr 4, 2022 · 3 comments
Closed

Fallback content for query loop block when there are no posts. #40014

AdsonCicilioti opened this issue Apr 4, 2022 · 3 comments

Comments

@AdsonCicilioti
Copy link

What problem does this address?

The user does not see anything if there is no content in the query loop, especially in a template for the search page in FSE.
A bad UX. Which forces us to create a template in PHP and evidence that FSE is not yet mature.

See, found posts:

image

When there are no posts:

image

What is your proposed solution?

I'm not sure, but we need a way to configure fallback content for this situation.

@carolinan
Copy link
Contributor

Hi!
In Gutenberg version 12.9.0 there is a new block that you can place inside the Query loop, called "no results".
The blocks that you place inside this container are shown when there are no results to show. You can place any blocks inside it.

@ndiego
Copy link
Member

ndiego commented Apr 4, 2022

Hi @AdsonCicilioti, I just tested and confirmed @carolinan's recommendation above. The No Results block was added in 12.9, here is the relevant PR: #38806. Note that this block will only be an option when you are adding a block directly to the Query Loop block. If you try and add the block to the Post Template block, it will not show up as an option. The setup you want looks like this:

image

Since there is a solution, I am going to close out this ticket, but please let me know if you have any additional questions!

@ndiego ndiego closed this as completed Apr 4, 2022
@AdsonCicilioti
Copy link
Author

Yes it's true! Thank you very much @carolinan and @ndiego !

One more thing, could there be any hint in the documentation indicating the use of these related blocks.
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants