{"id":41902,"date":"2016-02-12T10:21:26","date_gmt":"2016-02-12T10:21:26","guid":{"rendered":"https:\/\/wordpress.org\/plugins-wp\/wp-rest-api-pure-taxonomies\/"},"modified":"2016-03-01T08:31:51","modified_gmt":"2016-03-01T08:31:51","slug":"wp-rest-api-pure-taxonomies","status":"publish","type":"plugin","link":"https:\/\/vi.wordpress.org\/plugins\/wp-rest-api-pure-taxonomies\/","author":8839263,"comment_status":"closed","ping_status":"closed","template":"","meta":{"_crdt_document":"","version":"1.0","stable_tag":"1.0","tested":"4.4.34","requires":"4.4","requires_php":"","requires_plugins":"","header_name":"WP REST API - Pure Taxonomies","header_author":"Andrew MAGIK","header_description":"","assets_banners_color":"","last_updated":"2016-03-01 08:31:51","external_support_url":"","external_repository_url":"","donate_link":"","header_plugin_uri":"http:\/\/magiks.ru","header_author_uri":"http:\/\/magiks.ru\/","rating":5,"author_block_rating":0,"active_installs":500,"downloads":11399,"num_ratings":5,"support_threads":0,"support_threads_resolved":0,"author_block_count":0,"sections":["description","installation","faq","changelog"],"tags":[],"upgrade_notice":[],"ratings":{"1":0,"2":0,"3":0,"4":0,"5":"5"},"assets_icons":[],"assets_banners":[],"assets_blueprints":{},"all_blocks":[],"tagged_versions":["1.0"],"block_files":[],"assets_screenshots":[],"screenshots":[],"jetpack_post_was_ever_published":false},"plugin_section":[],"plugin_tags":[1556,610,23853,940,2300],"plugin_category":[57],"plugin_contributors":[],"plugin_business_model":[],"class_list":["post-41902","plugin","type-plugin","status-publish","hentry","plugin_tags-api","plugin_tags-categories","plugin_tags-rest-api","plugin_tags-taxonomies","plugin_tags-wp-api","plugin_category-taxonomy","plugin_committers-magikru"],"banners":[],"icons":{"svg":false,"icon":"https:\/\/s.w.org\/plugins\/geopattern-icon\/wp-rest-api-pure-taxonomies.svg","icon_2x":false,"generated":true},"screenshots":[],"raw_content":"<!--section=description-->\n<p>Now you have no need to make additional requests to get taxonomy info (term_id, name, slug, term_group, term_taxonomy_id, taxonomy, description, parent, count, filter) from their id that is available in the default json response.<\/p>\n\n<p>Now all available taxonomy data is available in 'pure_taxonomies' field from your json response. It works for all custom added taxonomies, and for custom post types.<\/p>\n\n<p>For example in 'wp-json\/wp\/v2\/posts' you can find default fields 'categories', 'tags' and name of custom added taxonomies that contain only its id. With this plugin you can also find new 'pure_taxonomies' field that include all available 'categories', 'tags' and custom taxonomies data.<\/p>\n\n<p><strong>Before:<\/strong>\n    {\n        ...\n        categories: [\n            3\n        ],\n        tags: [\n            2\n        ],\n        custom_taxonomy_name: [\n            1\n        ]\n        ...\n    }<\/p>\n\n<p><strong>After:<\/strong>\n    {\n        ...\n        pure_taxonomies: {\n            categories: [\n                {\n                    term_id: 3,\n                    name: \"First category\",\n                    slug: \"first-category\",\n                    term_group: 0,\n                    term_taxonomy_id: 3,\n                    taxonomy: \"category\",\n                    description: \"\",\n                    parent: 0,\n                    count: 3,\n                    filter: \"raw\",\n                    cat_ID: 3,\n                    category_count: 3,\n                    category_description: \"\",\n                    cat_name: \"First category\",\n                    category_nicename: \"first-category\",\n                    category_parent: 0\n                }\n            ],\n            tags: [\n                {\n                    term_id: 2,\n                    name: \"First tag\",\n                    slug: \"first-tag\",\n                    term_group: 0,\n                    term_taxonomy_id: 2,\n                    taxonomy: \"post_tag\",\n                    description: \"\",\n                    parent: 0,\n                    count: 2,\n                    filter: \"raw\"\n                }\n            ],\n            custom_taxonomy_name: [\n                {\n                    term_id: 1,\n                    name: \"Custom Taxonomy Name\",\n                    slug: \"custom-taxonomy-name\",\n                    term_group: 0,\n                    term_taxonomy_id: 1,\n                    taxonomy: \"custom_taxonomy_name\",\n                    description: \"\",\n                    parent: 0,\n                    count: 1,\n                    filter: \"raw\"\n                }\n            ]\n        }\n        ...\n    }<\/p>\n\n<p>Check my other useful rest-api plugins: <a href=\"https:\/\/wordpress.org\/plugins\/tags\/andrew-magik-rest-api\">https:\/\/wordpress.org\/plugins\/tags\/andrew-magik-rest-api<\/a>.<\/p>\n\n<!--section=installation-->\n<ol>\n<li>Double check you have the WordPress REST (v2) API installed and active<\/li>\n<li>Upload the plugin folder to the <code>\/wp-content\/plugins\/<\/code> directory, or install the plugin through the WordPress plugins screen directly.<\/li>\n<li>Activate the plugin through the 'Plugins' screen in WordPress<\/li>\n<\/ol>\n\n<!--section=faq-->\n<dl>\n<dt>How to add custom taxonomies into Rest API:<\/dt>\n<dd><p>\/**\n     * Add REST API support to an already registered taxonomy.\n     *\/\n        add_action( 'init', 'my_custom_taxonomy_rest_support', 25 );\n        function my_custom_taxonomy_rest_support() {\n            global $wp_taxonomies;<\/p>\n\n<pre><code>        \/\/Here should be a list of names of the already created custom taxonomies:\n        $taxonomy_names = array(\n            'clients',\n            'technologies'\n        );\n        foreach ( $taxonomy_names as $key =&gt; $taxonomy_name ) {\n            if (isset($wp_taxonomies[$taxonomy_name])) {\n                $wp_taxonomies[$taxonomy_name]-&gt;show_in_rest = true;\n                $wp_taxonomies[$taxonomy_name]-&gt;rest_base = $taxonomy_name;\n                $wp_taxonomies[$taxonomy_name]-&gt;rest_controller_class = 'WP_REST_Terms_Controller';\n            }\n        }\n    }\n<\/code><\/pre><\/dd>\n<dt>How to add custom post type into Rest API:<\/dt>\n<dd><p>\/**\n     * Add REST API support to an already registered post type.\n     *\/\n        add_action( 'init', 'my_custom_post_type_rest_support', 25 );\n        function my_custom_post_type_rest_support() {\n            global $wp_post_types;<\/p>\n\n<pre><code>        \/\/Here should be a name of your already created custom post type:\n        $post_type_name = 'portfolio';\n        if( isset( $wp_post_types[ $post_type_name ] ) ) {\n            $wp_post_types[$post_type_name]-&gt;show_in_rest = true;\n            $wp_post_types[$post_type_name]-&gt;rest_base = $post_type_name;\n            $wp_post_types[$post_type_name]-&gt;rest_controller_class = 'WP_REST_Posts_Controller';\n        }\n    }\n<\/code><\/pre><\/dd>\n<dt>Do you have other useful REST-API plugins?<\/dt>\n<dd><p>Yes, I have. You can check them by tag: <a href=\"https:\/\/wordpress.org\/plugins\/tags\/andrew-magik-rest-api\">https:\/\/wordpress.org\/plugins\/tags\/andrew-magik-rest-api<\/a>.<\/p><\/dd>\n\n<\/dl>\n\n<!--section=changelog-->\n<h4>1.0<\/h4>\n\n<ul>\n<li>Initial release!<\/li>\n<\/ul>","raw_excerpt":"This plugin include all available taxonomy attributes into the WordPress REST API (v2) without additional API requests.","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/vi.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin\/41902","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/vi.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin"}],"about":[{"href":"https:\/\/vi.wordpress.org\/plugins\/wp-json\/wp\/v2\/types\/plugin"}],"replies":[{"embeddable":true,"href":"https:\/\/vi.wordpress.org\/plugins\/wp-json\/wp\/v2\/comments?post=41902"}],"author":[{"embeddable":true,"href":"https:\/\/vi.wordpress.org\/plugins\/wp-json\/wporg\/v1\/users\/magikru"}],"wp:attachment":[{"href":"https:\/\/vi.wordpress.org\/plugins\/wp-json\/wp\/v2\/media?parent=41902"}],"wp:term":[{"taxonomy":"plugin_section","embeddable":true,"href":"https:\/\/vi.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_section?post=41902"},{"taxonomy":"plugin_tags","embeddable":true,"href":"https:\/\/vi.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_tags?post=41902"},{"taxonomy":"plugin_category","embeddable":true,"href":"https:\/\/vi.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_category?post=41902"},{"taxonomy":"plugin_contributors","embeddable":true,"href":"https:\/\/vi.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_contributors?post=41902"},{"taxonomy":"plugin_business_model","embeddable":true,"href":"https:\/\/vi.wordpress.org\/plugins\/wp-json\/wp\/v2\/plugin_business_model?post=41902"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}