Image not in the Json respond using WP API v2
-
Hi,
Thanks for a nice plugin, I’m trying to use it with the WP Rest API v2, to fetch the category image, so far I have not been able to make it work.
Requesting the categories I make a call like this https://thelonelycyclist.org/wp-json/wp/v2/recipe_categories
In the JSON output the image do not show up.
I did an edit in the JSON API category.php
function import_wp_object($wp_category) {
$this->id = (int) $wp_category->term_id;
$this->slug = $wp_category->slug;
$this->title = $wp_category->name;
$this->description = $wp_category->description;
$this->parent = (int) $wp_category->parent;
$this->post_count = (int) $wp_category->count;
// image:
$this->image = z_taxonomy_image_url($this->id);
}Adding the last line, I still do not get the image. How can I get the image in the WP API JSON result.
- The topic ‘Image not in the Json respond using WP API v2’ is closed to new replies.