[wp-trac] [WordPress Trac] #63339: WordPress 6.8 REST API returns all sticky posts regardless of per_page setting

WordPress Trac noreply at wordpress.org
Wed Apr 23 19:43:00 UTC 2025


#63339: WordPress 6.8 REST API returns all sticky posts regardless of per_page
setting
-------------------------------------+------------------------------
 Reporter:  se8820726                |       Owner:  (none)
     Type:  defect (bug)             |      Status:  new
 Priority:  normal                   |   Milestone:  Awaiting Review
Component:  REST API                 |     Version:  6.8
 Severity:  normal                   |  Resolution:
 Keywords:  has-patch needs-testing  |     Focuses:
-------------------------------------+------------------------------

Comment (by se8820726):

 Replying to [comment:2 abcd95]:
 > Hi @se8820726, and thanks for the ticket.
 >
 > I've been able to reproduce the problem exactly as you described. The
 issue occurs because in 6.8, when requesting posts with the `per_page`
 parameter but without specifying the sticky parameter, the system prepends
 all sticky posts to the result set without respecting the pagination
 limit.
 >
 > I've created a patch that ensures the `per_page` parameter is properly
 respected in all cases. The solution adds a check to ignore sticky post
 behavior when pagination is requested, but no explicit sticky preference
 is specified.
 >
 > Let me know if the patch tests well for you.


 in your patch with this request is there a default limit ?
 /wp-json/wp/v2/posts?sticky=true

 this request should not return all sticky posts.

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


More information about the wp-trac mailing list