-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Query Loop: It doesn't show sticky posts at the top when the query type is the default in the editor. #68595
base: trunk
Are you sure you want to change the base?
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for working on this, it would be great to have this fixed.
I don't think the logic is correct: When I switch the post type option on the query block to use pages, they show twice in the editor. If I then switch back from pages to posts, the pages still show in the editor.
Hi @carolinan, Thank you for pointing out the bug, I have fixed it and tested on my local |
I have tested order, filters, switching post type, include, exclude and only without finding any issues. |
// If sticky is not set, it will return all posts in the results. | ||
// If sticky is set to `only`, it will limit the results to sticky posts only. | ||
// If it is anything else, it will exclude sticky posts from results. For the record the value stored is `exclude`. | ||
if ( sticky === 'only' ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps these two conditions could be combined into one, where the value of sticky depends on if it is only/exclude?
It depends on what everyone prefers in terms of readability, but also on how we want to manage the introduction of ignore, #66222, which relies on this issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PR needs more work based on the conditions; the Query block might make three REST API calls to retrieve posts, negatively impacting the Site Editor loading performance.
Ideally, it should only make one and Sticky post logic should be baked in the REST controller.
Fixes #68570
What?
Fixes the issue where sticky posts were not appearing at the top of Query Loop block results in the editor view, while they do appear at the top on the front end.
Why?
There was an inconsistency between how sticky posts were displayed in the editor versus the front end. This caused confusion for users as the editor preview didn't accurately reflect what visitors would see on the site. The issue occurs because the editor view wasn't properly handling the sticky post ordering, while the PHP rendering on the front end did show sticky posts at the top by default.
Testing Instructions
Screenshots or screencast