0

Can I achieve this with wp_query? I only want to get pages that have parent selected.

I'm using JSON API plugin and need to make a http request - would this be possible with url wp query also? For example, I'm doing requests like this: http://example.com/api/get_posts/?post_type=page&posts_per_page=1&orderby=rand and they work perfectly fine.

Perhaps using something like post_parent__not_in => array() (but in a url-like fashion?)

A better question could be: How to use WP Query arguments that accept arrays within url?

Thanks for any help

0

To get only child pages (pages that have parent selected), you can use this query:

http://example.com/api/get_posts/?post_type=page&posts_per_page=1&orderby=rand&post_parent__not_in[]=

And that should also give you the answer for your second question, I guess ;)

If you want to pass array(1=>'foo', 2=>'bar') as param called my_array, you should use this query:

...&my_array[1]=foo&my_array[2]=bar
  • The &post_parent__not_in[]= did it. Never used this syntax and queries inside url so was quite confusing I must say. Thank you :) – trainoasis May 21 '15 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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