[wp-trac] [WordPress Trac] #61157: Blocks Query pagination NEXT & PREV produce incorrect URLs when queried via REST API

WordPress Trac noreply at wordpress.org
Thu Dec 5 07:26:52 UTC 2024


#61157: Blocks Query pagination NEXT & PREV produce incorrect URLs when queried via
REST API
--------------------------+------------------------------
 Reporter:  yelbaev       |       Owner:  (none)
     Type:  defect (bug)  |      Status:  new
 Priority:  normal        |   Milestone:  Awaiting Review
Component:  Permalinks    |     Version:  5.8
 Severity:  normal        |  Resolution:
 Keywords:  needs-patch   |     Focuses:  rest-api
--------------------------+------------------------------

Comment (by geekofshire):

 This issue also occurs with classic pagination functions like
 `get_pagenum_link` or `previous_posts_link` when these functions are
 called in the context of REST API or AJAX requests. The root cause is that
 the generated pagination URLs rely on `$_SERVER['REQUEST_URI']`, which
 leads to incorrect paths in these contexts. A simple fix is to use the
 `get_pagenum_link` filter to modify the generated URLs as needed. However,
 a more robust solution would be to introduce an argument in these
 functions, allowing developers to explicitly set or modify the base path,
 rather than relying on `$_SERVER['REQUEST_URI']` by default.

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


More information about the wp-trac mailing list