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

Bug: Query Loop shows posts in wrong order with "STICKY POSTS: Include" setting in block editor #1252

Open
frzsombor opened this issue Jun 23, 2024 · 0 comments
Labels
triage Awaiting review

Comments

@frzsombor
Copy link

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 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

  1. Add 3 new posts in WP
  2. Set the second as "sticky"
  3. Create a new page, add a query loop
  4. Set "STICKY POSTS: Include" and then "STICKY POSTS: Ignore"
  5. 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"

References:

https://developer.wordpress.org/rest-api/reference/posts/#arguments
WP-API/WP-API#2565 (old!)


@frzsombor frzsombor added the triage Awaiting review label Jun 23, 2024
@frzsombor 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage Awaiting review
Projects
None yet
Development

No branches or pull requests

1 participant