Query Loop block does not display search results in order of relevance #39285
Labels
[Block] Query Loop
Affects the Query Loop Block
Needs Technical Feedback
Needs testing from a developer perspective.
Description
Normally WordPress search results are sorted by relevance, using
relevance
fororderby
in the query. The Query Loop block however enforcesdate
as theorderby
argument by default when "Inherit query from template" is selected. This means that search results are only displayed in date order if the results are displayed using the Query Loop block, as they are in Twenty Twenty-Two.Step-by-step reproduction instructions
A workaround is to use the
pre_get_posts
hook to correct the order (props @felipeelia):Screenshots, screen recording, code snippet
No response
Environment info
WordPress 5.9.1
Twenty Twenty-Two 1.1
Gutenberg is not installed.
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
The text was updated successfully, but these errors were encountered: