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

WordPress Trac noreply at wordpress.org
Sat Apr 26 12:49:19 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 SirLouen):

 Replying to [comment:25 jorbin]:
 > Thanks @Mamaduka!
 >
 > I think the challenge is that the wp/v2/posts endpoint has now also been
 around for a long time with it's own "old and odd behavior" that we need
 to be careful with.
 >
 > I think the best path is that in 6.8.1, keep the `ignore_sticky_posts`
 param that was added, but change the default in the rest API to `true`
 which will restore the behavior that the endpoint had from 4.7 -> 6.7. The
 Query Block can be modified to call the endpoint with
 `ignore_sticky_posts` set to `false`. We can then look at adding a new
 endpoint (`wp/v3/posts`? `wp/v2/wp_query`?) in 6.9 that more closely
 resembles `WP_Query`. This would honor the original REST API behavior for
 posts collection, while maintaining support for sticky posts.

 I don't think this is a good idea entirely: #59801 should be reverted, as
 It's still buggy and needs more development. I've been looking into the
 code to find a quick fix, but it's not going to be as quick as I thought.

 The solution of setting the default `ignore_sticky` to `true` keeps the
 added functionality troubles provided by #59801 alive.

 Basically, if you change the URL param behavior, all sticky posts will
 return (regardless of whether they match the query or not). We could argue
 that it's weird to add "ignore_sticky=false" to the `slug` param, but for
 any other param it will also break the results as it does with `slug` and
 it's not that weird to use this. The sole scenario where "ignore_sticky"
 makes sense (and to which it seemed to be tested), was against the regular
 no-parameters query.

 So basically, my argument is that the "ignore_sticky" is partially broken,
 and it should be reverted for now.

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


More information about the wp-trac mailing list