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

[Block]: Query Loop - Add ability to limit search results by post type #70195

Open
cuemarie opened this issue Nov 18, 2022 · 4 comments
Open

Comments

@cuemarie
Copy link

cuemarie commented Nov 18, 2022

What

Add the ability to limit search results to certain post types in the Query Loop block.

Why

Allowing search results to filter by post type would mean users could easily set up a search for posts, portfolios, recipes, etc - which would be a nicer experience for their readers.


In FSE themes, the Search template uses the Query Loop block to display results - but you can't limit what those results include. Disabling inherit query from template breaks the search results altogether, and this is the only way to filter the Query Loop block to a specific post type.

Without such a filter, static pages also appear in search results, which can deliver a less sophisticated experience, like in this user example from 38075901-hc :

Markup 2022-11-18 at 12 49 33

Workaround

Supplying some CSS works as a way to hide Pages from search results for now, such as:

.search-results .type-page {
    display: none;
}

How

No response

@cuemarie cuemarie added [Pri] Normal Schedule for the next available opportuinity. [Type] Feature Request Feature requests [Feature] Full Site Editor The site editor. [Block] Query Loop labels Nov 18, 2022
@cuemarie
Copy link
Author

Could be related to work happening here: WordPress/gutenberg#24934

Though my eyes are crossing trying to comprehend all the work going on there 😁

@kavyagokul
Copy link

📌 SCRUBBING : RESULT

  • Tested on P2 - Uncertain
  • Tested on Simple - Replicated
  • Tested on AT - Replicated
  • Tested on Self-hosted - Replicated
  • Replicable on Core - Yes

📌 FINDINGS/SCREENSHOTS/VIDEO

  • From what I understand, this is the intended behavior, seeing how the query loop fundamentally works.
  • The linked issue in core doesn't seem to address this.

📌 ACTIONS

  • Await author feedback

📌 Message to Author

  • @cuemarie Do you think this is probably plugin territory, as the search page by default supplies its own query? I know this is a feature request, but maybe we can map out a bit more detail before we file a core bug.

@kavyagokul kavyagokul added [Pri] Low Address when resources are available. [Platform] Simple [Platform] Atomic and removed [Pri] Normal Schedule for the next available opportuinity. labels Nov 22, 2022
@cuemarie
Copy link
Author

cuemarie commented Nov 23, 2022

Hey @kavyagokul ! I don't really know how to answer your follow up question 😄 Apologies for my ignorance here! To me, it made sense to consider this a core / built-in feature, as FSE sites with search templates and query loop blocks are all available on any site at WordPress.com, including free sites.

I suppose a plugin could be developed to solve this issue, but that's not much more helpful to WordPress.com users on the Personal or free plan than a CSS workaround.

Not really an answer, but does that answer your question in terms of my thoughts? ☺️ Thanks for giving it a look!

@kavyagokul
Copy link

kavyagokul commented Nov 24, 2022

I haven't thought long and hard about this, but I just found this bug report which might actually lead to an implementation like this
WordPress/gutenberg#30706

EDIT
On second thought, I'm going to add this to the cross repo watchlist, to track that core bug for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Gutenberg / WP Core
Development

No branches or pull requests

2 participants