Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add WP REST API support to certain taxonomies
/**
* Add REST API support to an already registered taxonomy.
*/
add_filter( 'register_taxonomy_args', 'my_taxonomy_args', 10, 2 );
function my_taxonomy_args( $args, $taxonomy_name ) {
if ( 'freebbble-type' === $taxonomy_name || 'freebbble-license' === $taxonomy_name ) {
$args['show_in_rest'] = true;
// Optionally customize the rest_base or rest_controller_class
$args['rest_controller_class'] = 'WP_REST_Terms_Controller';
}
return $args;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment