block editor – Full Site Editing (FSE) – How do I display no results with wp:query?


I have inherited a theme which is built with FSE. Inside index.html which is set to display the blog posts, I have a query as such:

<!-- wp:query {"tagName":"main","queryId":0,"query":{"perPage":8,"pages":0,"offset":0,"postType":"post","categoryIds":[],"tagIds":[],"order":"desc","orderBy":"date","author":"","search":"","exclude":[],"sticky":"","inherit":true},"displayLayout":{"type":"list","columns":1}} -->
<main class="wp-block-query">

    <!-- wp:pattern {"slug":"epi/simple-header"} /-->

    <!-- wp:search {"label":"Search","placeholder":"Search","buttonText":"Search","buttonPosition":"button-inside","buttonUseIcon":true,"required":false} /-->

    <!-- wp:post-template {"layout":{"inherit":true}} -->
        <!-- wp:post-title {"isLink":"true"} /-->
        <!-- wp:template-part {"slug":"posts/post-metadata", "tagName":"div", "className":"post__metadata"} /-->

        <!-- wp:post-featured-image /-->
        <!-- wp:post-excerpt {"moreText":"Read more"} /-->
    <!-- /wp:post-template -->

    <!-- wp:query-pagination -->
        <!-- wp:query-pagination-previous /-->
        <!-- wp:query-pagination-numbers /-->
        <!-- wp:query-pagination-next /-->
    <!-- /wp:query-pagination -->

<!-- /wp:query -->

Is there a way to add a no-results template after the <!-- /wp:query --> tag, i.e. is there a core block to achieve this or do I need to use a custom shortcode to output some custom logic and content?

My experience so far of FSE removes some of the power of conditional statements with the traditional method of creating WordPress themes.

I am also confused what to refer to these: wp:query and wp:post-featured-image, are they “tags”, “markup”, “gutenberg tags” (I never know the correct way to say them).

Web Assembler 1 year 2023-01-10T10:14:19-05:00 0 Answers 0 views 0

Leave an answer