Opened 9 years ago
Closed 9 years ago
#41253 closed defect (bug) (worksforme)
category meta endpoint always returns an empty array
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | 4.8 |
| Component: | REST API | Keywords: | |
| Focuses: | rest-api | Cc: |
Description
As the title says, when I use categories route "/wp/v2/categories/" it returns an array of "category" objects, as stated in the documentation. But it always returns an empty array for meta object, whether it has meta fields or not. However, when I use get_term_meta() I get an associative array that contains all meta fields as key => value pairs -as expected-.
Change History (5)
#2
follow-up:
↓ 4
@
9 years ago
Is your category meta registered? Meta keys that you want to appear in REST API responses must be registered with the show_in_rest option set to true (or to an array of options).
Note: See
TracTickets for help on using
tickets.
Have you made any direct database updates recently? I just encountered this issue and I solved it by resetting the taxonomy cache in the wp_options table. Look for an option_name like ${taxonomy}_children where ${taxonomy} is the hierarchical taxonomy you are trying to query, example: category_children. If you set that back to null, the next time WP runs the query it will recache the results.