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

Fix query-no-results block from showing when their is one search result #47793 #50942

Closed
wants to merge 1 commit into from

Conversation

petitphp
Copy link
Contributor

This allows inner blocks to operate on the correct query when checking for the state of the loop.

What?

This is an attempt at addressing #47793
Store the post-template block's query in globals. In post-content and post-featured-image blocks, use the query if available instead of the global one.

⚠️ Warning : The current behavior was meant to fix an issue where some plugins would work properly because the check to in_the_loop would fail. This PR should be tested to see if it reintroduces the bug or not.

Why?

This change is to avoid manipulating the global wp_query in the post-content and post-featured-image blocks.

These blocks are typically used as inner blocks of the post-template block. When the post-template block is configured to use the global wp_query it'll create a clone of it instead of using it directly, so the two aforementioned blocks shouldn't operate on the global one.

How?

In post-template, the query is stored in a global. In the blocks post-content and post-featured-image this query is retrieved and used instead of using the functions for the global query.

Testing Instructions

  1. Activate Twenty Twenty-Three, or insert the No Results block in a search template
  2. Search for a keyword that should have 1 search result (e.g. "hello world")
  3. The No Results block should not be show
@petitphp petitphp requested a review from ajitbohra as a code owner May 25, 2023 08:28
This allows inner blocks to operate on the correct query when checking
for the state of the loop.
@skorasaurus skorasaurus added the Needs Technical Feedback Needs testing from a developer perspective. label Jun 14, 2023
@ocean90
Copy link
Member

ocean90 commented Aug 30, 2023

This now obsoleted by #49904 and #53772.

@ocean90 ocean90 closed this Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Technical Feedback Needs testing from a developer perspective.
3 participants