Opened 9 years ago
Closed 9 years ago
#41253 closed defect (bug) (worksforme)
category meta endpoint always returns an empty array
| Reported by: | MrG0lden | Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | REST API | Version: | 4.8 |
| Severity: | normal | Keywords: | |
| Cc: | Focuses: | rest-api |
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.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)
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.