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

Post Template returns empty string when no results found #36224

Closed
iandunn opened this issue Nov 4, 2021 · 5 comments
Closed

Post Template returns empty string when no results found #36224

iandunn opened this issue Nov 4, 2021 · 5 comments
Labels
[Block] Post Template Affects the Post Template Block [Status] In Progress Tracking issues with work in progress

Comments

@iandunn
Copy link
Member

iandunn commented Nov 4, 2021

Description

I expected index.php to return No results found like edit.js does, but it returns an empty string.

if ( ! $query->have_posts() ) {
return '';
}

if ( ! posts.length ) {
return <p { ...blockProps }> { __( 'No results found.' ) }</p>;
}

Step-by-step reproduction instructions

  1. Setup a FSE theme
  2. Add a search.html template w/ the following:
    <!-- wp:query {"queryId":1,"query":{"perPage":10,"postType":"any","inherit":true}} -->
    	<div class="wp-block-query">
    		<!-- wp:post-template -->
    			<!-- wp:post-title {"level":5,"isLink":true} /-->
    
    			<!-- wp:post-excerpt /-->
    		<!-- /wp:post-template -->
    	</div>
    <!-- /wp:query -->
  3. Browse to /?s=supercalifragilisticexpialidocious

Screenshots, screen recording, code snippet

No response

Environment info

Please confirm that you have searched existing issues in the repo.

Yes

Please confirm that you have tested with all plugins deactivated except Gutenberg.

Yes

@iandunn
Copy link
Member Author

iandunn commented Nov 4, 2021

Related: #29521

@iandunn
Copy link
Member Author

iandunn commented Nov 4, 2021

Also related: #33476

@ramonjd
Copy link
Member

ramonjd commented Feb 2, 2022

I think this issue should be part of a bigger drive to make the "no results" state configurable.

Here are two issues that raise this:

I threw up #38437 in haste, thinking that showing a message on the frontend, one that is consistent with the editor experience, would be a good thing.

But upon reflection I asked myself whether displaying text that isn't editable is something that might irk users, and also go against the spirit of theme editor. Do you think it might be best to wait until we deliver an editable solution?

@iandunn iandunn removed their assignment Mar 18, 2022
@carolinan
Copy link
Contributor

Can this issue be closed as fixed by #38806 ?

@iandunn
Copy link
Member Author

iandunn commented Mar 27, 2023

I think that'll work, thanks!

@iandunn iandunn closed this as completed Mar 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Post Template Affects the Post Template Block [Status] In Progress Tracking issues with work in progress
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants