Last active
December 5, 2019 04:56
-
-
Save hafizrahman/04265e530b2823792fa53c802a4894f2 to your computer and use it in GitHub Desktop.
Add WP REST API support to certain taxonomies
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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