[wp-trac] [WordPress Trac] #61157: Blocks Query pagination NEXT & PREV produce incorrect URLs when queried via REST API
WordPress Trac
noreply at wordpress.org
Tue May 7 06:35:08 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 | Keywords: needs-patch
Focuses: rest-api |
--------------------------+-----------------------------
Core/query block when rendered by REST API call, for example `/wp-
json/v2/pages/%ID%`, generates incorrect URLs for Prev and Next buttons.
URLs get generated based on `$_SERVER['REQUEST_URI']` instead of **current
page permalink**.
Example: for prev link I get `/wp-json/wp/v2/pages/80?query-19-page=1`
instead of `/portfolio/?query-19-page=1`
As far as I can see, it's caused by the use of `add_query_arg` function
without url to work on. Adding get_permalink() as a last parameter fixes
the issue
https://github.com/WordPress/WordPress/blob/97c3f240341043e8a0063a7ddfa40797c4a1ee19
/wp-includes/blocks/query-pagination-previous.php#L48
https://github.com/WordPress/WordPress/blob/97c3f240341043e8a0063a7ddfa40797c4a1ee19
/wp-includes/blocks/query-pagination-next.php#L58
--
Ticket URL: <https://core.trac.wordpress.org/ticket/61157>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list