I’m a little new to WordPress and the JSON API so forgive me if this is a newbie question but i’m trying to get all of the posts of a few different custom post types and return them as JSON via my own JSON controller (extending the JSON API)
if I do this:
$posts = $json_api->introspector->get_posts(array('post_type' => array('post','tweet','gallery','video','music'), 'post_parent' => 0, 'order' => 'ASC', 'orderby' => 'date', 'numberposts' => 100000000000));
echo count($posts);
I only get “10” posts but there are a lot more in the db. Whereas if I do this:
echo count(get_posts(array('post_type' => array('post','tweet','gallery','video','music'), 'post_parent' => 0, 'order' => 'ASC', 'orderby' => 'date', 'numberposts' => 100000000000)));
I get “74”, the correct number of posts in the db. Essentially the JSON API is limiting the returned value to only 10 posts. I’m pretty sure I can hack the JSON API plugin to allow more but that seems like it would mess up my code for any API upgrades.
Is there a way to set the JSONAPI->introspector post number to “all”
Thanks
I’m answering my own question because it might be useful to someone else sometime.
After reading through the somewhat sparse documentation on the wordpress plugin directory and getting nowhere. I found a variable in the JSON API code here’s how it works PS -1 just mean “all”:
you can set the count to whatever you want before making the api call.