dphiffer / wp-json-api

WordPress JSON API
http://wordpress.org/extend/plugins/json-api/
258 stars 181 forks source link

post__not_in is not working #25

Closed ghost closed 10 years ago

ghost commented 10 years ago

Hej!

I can't get post__not_in parameter work when I fetch a bunch of posts. When use the following to fetch posts www.example.com/api/get_posts/?post_type=custom_post_type&post__not_in=array(1,2,3,4,6)&count=6&offset=0, everything works fine but the posts with the ids 1,2,3,4,5 are not excluded in the response.

What am I doing wrong here?

ghost commented 10 years ago

Opted for another solution that does the same job due to lack documentation and response from community.

jkeary commented 9 years ago

I know its a little late for this, but for anyone in the future needing help:

excluded_posts = ''; for (var i=0; i < array_of_ids.length; i++) { excluded_posts += '&post__not_in[]=' + array_of_ids[i]; } var url = 'www.example.com/api/get_posts/post_type=custom_post_type&count=6&offset=0' + excluded_posts;

note: array_of_ids is an array of ids you want to exclude.