Repository navigation
REST API: Apply the query arguments of a taxonomy to the terms of a post and their total - #16406
jorgefilipecosta wants to merge 1 commit into
Conversation
…ost and their total. When a taxonomy is registered with `args`, the terms endpoint applied them to the terms it listed for the `post` filter but not to `X-WP-Total`, and they could replace the requested page, so some terms could not be reached. The terms of a post are now read with `get_terms()` and `object_ids`, with the taxonomy's arguments merged in as they are without the `post` filter, so the list and the total use the same arguments. With or without the filter, the paging and the kind of result stay the request's. See #66914.
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Props Bot commandsYou can trigger Props Bot actions by commenting on this PR:
|
Test using WordPress PlaygroundThe changes in this pull request can previewed and tested using a WordPress Playground instance. WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser. Some things to be aware of
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
Follow up to #16102, where the same issue was fixed for the term abilities.
When a taxonomy is registered with
args, the terms endpoint applies them to the terms it lists for thepostfilter but not toX-WP-Total, and they can replace the requested page, so some terms can't be reached.This PR implements the following changes:
get_terms()andobject_idsinstead ofwp_get_object_terms(), with the taxonomy's arguments merged in as they are without thepostfilter.number,offsetandfieldsfrom the taxonomy's arguments are skipped on both paths, so the requested page is always the one returned.postpath no longer runs thewp_get_object_terms_args,get_object_termsandwp_get_object_termsfilters.The PR was drafted with AI assistance and reviewed by me.
Trac ticket: https://core.trac.wordpress.org/ticket/66914
Testing
Verify unit tests are passing: