#62500 closed defect (bug) (fixed)
REST API: Terms controller doesn't respect taxonomy's default query args
Reported by: | Bernhard Reiter | Owned by: | Bernhard Reiter |
---|---|---|---|
Milestone: | 6.8 | Priority: | normal |
Severity: | normal | Version: | trunk |
Component: | REST API | Keywords: | has-patch |
Focuses: | Cc: |
Description (last modified by )
It is possible to supply a default set of default query args
to `register_taxonomy()` which will be used when querying a list of terms -- for example, orderby
in order to specify how the resulting list of terms should be sorted.
However, those default query args are not respected by the Terms REST API controller, if the request doesn't contain a post ID.
Change History (6)
This ticket was mentioned in PR #7848 on WordPress/wordpress-develop by @Bernhard Reiter.
2 months ago
#2
- Keywords has-patch added
See https://github.com/WordPress/gutenberg/pull/67154. More details to follow.
TODO:
- [ ] Test coverage
Trac ticket: https://core.trac.wordpress.org/ticket/62500
@Bernhard Reiter commented on PR #7848:
8 weeks ago
#4
I'll go ahead and merge this per https://github.com/WordPress/gutenberg/pull/67154#pullrequestreview-2454037832:
[T]he Core backport in https://github.com/WordPress/wordpress-develop/pull/7848 also makes perfect sense. The REST controller should apply the taxonomy's default args.
#5
@
8 weeks ago
- Owner set to Bernhard Reiter
- Resolution set to fixed
- Status changed from new to closed
In 59458:
@Bernhard Reiter commented on PR #7848:
8 weeks ago
#6
Committed to Core in https://core.trac.wordpress.org/changeset/59458.
The controller's
get_items()
method has two code branches:get_items()
uses `wp_get_object_terms()` to get the terms associated with the given post. That function includes code to respect the default queryargs
specified when the taxonomy was registered.For the practical impact, more background, and a fix in the GB repo, see https://github.com/WordPress/gutenberg/issues/65052 and https://github.com/WordPress/gutenberg/pull/67154.