Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

[Mods: I have cross posted this in stack overflow a minute ago but wasn't sure which site would be better to post this question please let me know and I'll remove as appropriate]

share|improve this question

2 Answers 2

This will remove limit from child post requests

  1. Open file singletons/introspector.php within JSON Api plugin folder.
  2. add 'showposts' => -1 after 'orderby' => 'menu_order'
share|improve this answer
    
A link to another support request? Honestly? –  kaiser Nov 23 '12 at 15:47
up vote 0 down vote accepted

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":

$json_api->query->count=-1;
$posts = $json_api->introspector->get_posts(array('post_type' => array('post','tweet','gallery','video','music'), 'post_parent' => 0, 'order' => 'ASC', 'orderby' => 'date', 'numberposts' => 4));
echo count($posts);

you can set the count to whatever you want before making the api call.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.