I created 1 custom post type with 2 custom taxonomy. Installed http://wordpress.org/extend/plugins/json-api/ and tried to reach result with:
http://example.com/api/get_recent_posts?dev=1&post_type=myposttype
well it gives me custom posts but not giving those post’s custom taxonomies
“categories”: [],
“tags”: [],
How can i query custom taxonomies with json api?
Actually i am trying to create a simple iphone app with jquery mobile + phonegap. Maybe you know a better way then json api?
I would have done it as following, I am sure experts here will have a better way but following is what I could come up with in hurry.
First create your controller file in your theme directory (or any other if you like) with the following content. For this example the file name is korkmaz.php
UPDATE 1: Please replace the previous korkmaz.php because extending introspector was dangerous many unwanted functions were exposed via URI. Now we have a new JSON_API_Korkmaz_Controller class which does not extend any other class and We have removed the JSON_API_CustomPost class.
UPDATE 2: Now supports querying custom taxonomies, see the example at the bottom. Includes new model class JSON_API_Term to represent term of any type of taxonomy.
Now add following to your theme’s functions.php
Now goto Json API settings page and enable your korkmaz controller.
Now you can access your custom post types with all of the associated taxonomies at the following url:
http://example.com/api/korkmaz/get_recent_posts/?post_type=myposttype
You can query any type of taxonomy (including custom taxonomies) using the following example:
http://example.com/api/korkmaz/get_taxonomy_posts/?taxonomy=my_custom_taxonomy&slug=my_term_slug
I have just tested this (I am doing the exact same thing for a project) and it worked fine for me.
Added tags to a custom post type, ran this:
And the json file looked like so:
Are you sure that you added the custom taxonomies to the Custom Post Type?
If you are looking to do something more complex, like define a hierarchical structure of custom taxonomies, this link might help you.
There ARE hooks available. http://wordpress.org/extend/plugins/json-api/other_notes/#Filter:-json_api_controllers