[wp-trac] [WordPress Trac] #63307: REST API: Returns incorrect post when querying by slug if sticky posts exist

WordPress Trac noreply at wordpress.org
Fri Apr 25 16:05:02 UTC 2025


#63307: REST API: Returns incorrect post when querying by slug if sticky posts
exist
-------------------------------------------------+-------------------------
 Reporter:  wpmudevsupport13                     |       Owner:  (none)
     Type:  defect (bug)                         |      Status:  new
 Priority:  normal                               |   Milestone:  6.8.1
Component:  REST API                             |     Version:  6.8
 Severity:  critical                             |  Resolution:
 Keywords:  changes-requested has-testing-info   |     Focuses:  rest-api
  has-unit-tests dev-feedback has-patch          |
-------------------------------------------------+-------------------------

Comment (by Mamaduka):

 Thanks for the ping, @jorbin!

 If I'm not mistaken, the actual behavior is coming from `WP_Query`. It's
 an old and odd behavior that we have to maintain for backward
 compatibility. These "gotchas" are also mentioned in the documentation.

 Now that we have fixed the sticky post display for the REST API, it also
 inherits the same query behavior.

 The resolution should honor the original REST API behavior for posts
 collection, while maintaining support for sticky posts. I've included a
 similar case for the `post__in` filter, but unfortunately, other cases
 slipped my mind. See: https://github.com/Mamaduka/wordpress-
 develop/blob/f01ff83ac372867253e4e757c5843add4ef83bd9/src/wp-includes
 /rest-api/endpoints/class-wp-rest-posts-controller.php#L341-L347.

 Regarding #63339. This is expected behavior; unless ignored, the sticky
 posts are prepended to the first page results, ignoring the `per_page`
 parameter. It was a bug stopping the Query block from working correctly in
 the editors.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/63307#comment:24>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list