Make WordPress Core

Opened 4 months ago

Closed 3 months ago

Last modified 3 months ago

#60493 closed feature request (reported-upstream)

Query loop block: Search Template Issues

Reported by: rawdolphe's profile rawdolphe Owned by:
Milestone: Priority: normal
Severity: normal Version: 6.4.3
Component: Editor Keywords:
Focuses: Cc:


Hi, I am testing the Search template (as shipped in 2024) and there is a big problem, I am only using the WordPress 2024 theme.

  1. When I set the Block Query Loop > Settings > to Inherit query from template (default setting) all is well; if I do a search it works as advertised – we see Posts and Pages…
  1. However, when I set the Block Query Loop > Settings > POST TYPE > to Posts = BIG PROBLEM; when I do a Search it outputs ALL the posts regardless of the keyword used for the search - it doesn't seem to do anything at all regardless of the keyword used. BROKEN feature?
  1. Exact same problem as '2' above when set to 'Pages'.

PS: I also spotted other bugs with the Search Block when located in the menu, but will reserve this for another report.

Change History (7)

#1 @poena
3 months ago

  • Keywords reporter-feedback added
  • Severity changed from critical to normal
  • Summary changed from Search Template Issues in 2024 to Query loop block: Search Template Issues

Hi @rawdolphe

What you are describing is how the query loop block works.
It stops using the search results query when the option "inherit from template" is turned off.
This also happens on archive pages.
That is why the theme has set this option to enabled by default.

This happens in every block theme, not only in the theme Twenty Twenty-Four, and it is the current intended behavior.

If you can describe what you were trying to do: I mean what result you expected, then I can try to help check in the Gutenberg GitHub repository if there is a feature request already opened for it.
Bug reports and feature requests for blocks are handled in the Gutenberg GitHub repository.

Were you trying to create a search results page for a custom post type?

#2 @rawdolphe
3 months ago

Hi @poena,

Thanks a lot for your reply.

Well, I have actually tried with the Category template and it seemed to work as it should, but NOT with the Search template.

No, I am NOT using a custom post. All standard, nothing extra.

BTW: To clarify further, I have seen videos on YouTube explaining the Search options in Twenty Twenty Three and it worked fine! i.e; if you choose 'Post' only it will only show Posts in the search results, but with 2024, setting it to Post OR Page doesn't even work, it seems to do NOTHING! That's what I am talking about.

What I am trying to do is very simple, but maybe I am having trouble explaining it, I'll try again:

Ok, in the 'Search template', in 2024, go to 'Query Loop' then go to 'Settings', as default it is set to 'Inherit query from template'. When you do a search, i.e /?s=any_keyword it will pull anything with the keyword, from Posts AND Pages.

Now, as above, but simply change 'Settings' to 'POST TYPE > Post', Save and do a search...
In my case, it doesn't do anything at all. It looks and feels broken, nothing happens. Same if I set it to 'Pages'. Is there more to it?

Now, to confirm to myself that there was a problem with the Search template (as I understood it), I installed a free plugin called Ajax Search Lite - to see if I could output Posts ONLY from searches; BUT a *very important* step BTW, is that we have to make sure that in the 'Search template' the 'Query loop' is set to 'Inherit query from template', otherwise same problem as explained above when set to Posts or Pages only (not both), it won't work.

So, after installing Ajax Search lite, I setup the plugin to show Posts ONLY, and sure enough, it worked, even with the built-in WordPress Search, when I search, it pulls the Posts only. And one important thing to note, is that I don't even have to use the Search widget from the Ajax Search Lite plugin, meaning that by simply installing this plugin it fixes the issue, as long you set it to display Posts only, or Pages in the plugin itself (NOT in the Search template).

I am very sorry for the very long post, but unless I overlooked something simple, as far as I am concerned the 'Search template' in 2024 is broken when set to show Posts or Pages—it doesn't do anything at all.

I'll attach a screenshot, please let me know if this setting in the 'Search template' is supposed to output Posts only (and yes I also played with the Filters - it made no difference), OR if when set to Post, it's supposed to do nothing at all!?

Last edited 3 months ago by rawdolphe (previous) (diff)

#3 @rawdolphe
3 months ago

In the following YouTube video, you can see the Search template settings (POST TYPE: Post...) at 5:15 — as shown in the screenshot in my previous reply.

That's just another YouTube video showing the Search template settings in Gutenberg, I only started to Google this because I believed there was a problem.

#4 @poena
3 months ago


It is still unclear to me what you are trying to do.

You are describing what options you are changing, but not what your goal is.

You wrote that the search results are showing both posts and pages. Are you trying to show only posts?

It is not possibly to set the filters you are describing when the option "inherit from template" is enabled. And you can see in the help text below the option, that it needs to be enabled on the search template.

It might look like it is working on archives, because the archives do not need to filter the results with a search query, so it can display all the results according to the block settings.

I can't speak for what is in the video. There is no way to determine that it is showing the correct results without having a copy of the content.

#5 @rawdolphe
3 months ago

Hi again,

What I am trying to do is VERY simple, but hard to explain it seems;

When I search with a keyword, I would like to show Posts ONLY (not pages, not pages AND posts).

I only want to show posts in my search.

It's not working.

What I am doing wrong? Why is there a setting to show Posts or Pages in settings and why it doesn't work?

#6 @poena
3 months ago

  • Component changed from Query to Editor
  • Keywords reporter-feedback removed
  • Milestone Awaiting Review deleted
  • Resolution set to reported-upstream
  • Status changed from new to closed
  • Type changed from defect (bug) to feature request

I am going to close this as reported upstream.

This is not a bug with the block. The feature request is handled in the Gutenberg GitHub repository.

#7 @rawdolphe
3 months ago

Hi, ok fine.

As you mentioned "Bug reports and feature requests for blocks are handled in the Gutenberg GitHub repository." I just went there on your recomendation.

I haven't read the replies there yet, will check ASAP.

I am still not sure how this is a feature request anyway, as we should be able to search for Posts only and not forced to show Posts AND Pages, as it makes the search output very messy.

Thank you

Note: See TracTickets for help on using tickets.