You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If I add a Query Loop in a page and set "STICKY POSTS: Include", it shows the posts in the same order as the "STICKY POSTS: Ignore" setting, so basically it also ignores the posts' "sticky" status. The rendered page works correctly (with "Include", the sticky posts are on top, and below them are the non-sticky ones). This is caused by the fact that the WP REST API only has a simple sticky parameter that can be set true or false (for including or excluding sticky posts), but it always returns the posts in publish date order and ignores the posts' sticky attribute. I also found that a custom stickyPosts parameter is added by GB to the REST API request but it has no effect. I suggest that in this case, we should either order the posts correctly with React on the frontend, or extend WP rest api to respect the stickyPosts parameter and return the results accordingly.
Steps to reproduce
Add 3 new posts in WP
Set the second as "sticky"
Create a new page, add a query loop
Set "STICKY POSTS: Include" and then "STICKY POSTS: Ignore"
Compare results
Expected behavior
When I set "STICKY POSTS: Include", sticky posts should be on top in the Query Loop.
Actual behavior
When I set "STICKY POSTS: Include", sticky posts are ignored and post are in the same order as with "STICKY POSTS: Ignore"
frzsombor
changed the title
Query Loop shows posts in wrong order with "STICKY POSTS: Include" setting in block editor
Bug: Query Loop shows posts in wrong order with "STICKY POSTS: Include" setting in block editor
Jun 23, 2024
Description
If I add a Query Loop in a page and set "STICKY POSTS: Include", it shows the posts in the same order as the "STICKY POSTS: Ignore" setting, so basically it also ignores the posts' "sticky" status. The rendered page works correctly (with "Include", the sticky posts are on top, and below them are the non-sticky ones). This is caused by the fact that the WP REST API only has a simple
sticky
parameter that can be set true or false (for including or excluding sticky posts), but it always returns the posts in publish date order and ignores the posts' sticky attribute. I also found that a customstickyPosts
parameter is added by GB to the REST API request but it has no effect. I suggest that in this case, we should either order the posts correctly with React on the frontend, or extend WP rest api to respect thestickyPosts
parameter and return the results accordingly.Steps to reproduce
Expected behavior
When I set "STICKY POSTS: Include", sticky posts should be on top in the Query Loop.
Actual behavior
When I set "STICKY POSTS: Include", sticky posts are ignored and post are in the same order as with "STICKY POSTS: Ignore"
References:
https://developer.wordpress.org/rest-api/reference/posts/#arguments
WP-API/WP-API#2565 (old!)
The text was updated successfully, but these errors were encountered: