This plugin include all available taxonomy attributes into the WordPress REST API (v2) without additional API requests.
Author: | Andrew MAGIK (profile at wordpress.org) |
WordPress version required: | 4.4 |
WordPress version tested: | 4.4.2 |
Plugin version: | 1.0 |
Added to WordPress repository: | 12-02-2016 |
Last updated: | 01-03-2016
Warning! This plugin has not been updated in over 2 years. It may no longer be maintained or supported and may have compatibility issues when used with more recent versions of WordPress.
|
Rating, %: | 100 |
Rated by: | 5 |
Plugin URI: | http://magiks.ru |
Total downloads: | 9 624 |
Active installs: | 700+ |
Click to start download
|
FAQ
How to add custom taxonomies into Rest API:
/**
* Add REST API support to an already registered taxonomy.
*/
add_action( ‘init’, ‘my_custom_taxonomy_rest_support’, 25 );
function my_custom_taxonomy_rest_support() {
global $wp_taxonomies;
//Here should be a list of names of the already created custom taxonomies:
$taxonomy_names = array(
'clients',
'technologies'
);
foreach ( $taxonomy_names as $key => $taxonomy_name ) {
if (isset($wp_taxonomies[$taxonomy_name])) {
$wp_taxonomies[$taxonomy_name]->show_in_rest = true;
$wp_taxonomies[$taxonomy_name]->rest_base = $taxonomy_name;
$wp_taxonomies[$taxonomy_name]->rest_controller_class = 'WP_REST_Terms_Controller';
}
}
}
How to add custom post type into Rest API:
/**
* Add REST API support to an already registered post type.
*/
add_action( ‘init’, ‘my_custom_post_type_rest_support’, 25 );
function my_custom_post_type_rest_support() {
global $wp_post_types;
//Here should be a name of your already created custom post type:
$post_type_name = 'portfolio';
if( isset( $wp_post_types[ $post_type_name ] ) ) {
$wp_post_types[$post_type_name]->show_in_rest = true;
$wp_post_types[$post_type_name]->rest_base = $post_type_name;
$wp_post_types[$post_type_name]->rest_controller_class = 'WP_REST_Posts_Controller';
}
}
Do you have other useful REST-API plugins?
Yes, I have. You can check them by tag: https://wordpress.org/plugins/tags/andrew-magik-rest-api.
ChangeLog