Skip to content

Instantly share code, notes, and snippets.

@robertdevore
Created May 19, 2018 19:53
Show Gist options
  • Select an option

  • Save robertdevore/ddea5ff761117e900549becd99e6c3c5 to your computer and use it in GitHub Desktop.

Select an option

Save robertdevore/ddea5ff761117e900549becd99e6c3c5 to your computer and use it in GitHub Desktop.
The current way WP Dispensary adds in the custom flowers_category taxonomy to the Flowers REST API endpoint
<?php
/**
* Add Category taxonomy for the Flowers Custom Post Type
*/
function flowers_category( $data, $post, $request ) {
$_data = $data->data;
$_data['flowers_category'] = get_the_term_list( $post->ID, 'flowers_category', '', ' ', '' );
$data->data = $_data;
return $data;
}
add_filter( 'rest_prepare_flowers', 'flowers_category', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment