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
Related Posts:
- Why use JSON API to display recent posts?
- Querying A Post That Includes Two Taxonomies Using JSON Rest API
- Simple Apex Charts with jQuery not working
- Exclude post ID from wp_query
- Can I force WP_Query to return no results?
- Use the page slug in a WP_Query?
- paginate_links() adds empty href to first page and previous link
- Using OR conditions in meta_query for query_posts argument
- Get array of posts from the current archive page loop
- Get posts by menu ID
- count posts from custom taxonomy terms by year
- In loop: posts have thumbnail AND other variables
- How to grab metabox value in wp_query meta_query key
- Woocommerce query by price range and custom meta key
- Add and in the header while looping over custom query in page template
- Stop all SQL_CALC_FOUND_ROWS wordpress queries
- Move posts to top of WP_Query if in certain Taxonomy?
- Pagination not working on static page
- How can I create a WP_Query that returns posts where one meta_value
- ‘paged’ in wp_query doesn’t work
- Sorting meta_value as integer doesn’t work
- Get posts from the Main site to sub site – WordPress MultiSites Network
- Custom Field Query – Meta Value is Array
- Can certain (site-crashing) limitations on WP_Query in shortcode be overcome?
- Get array of current post term ID’s
- WP_Query for showing specific post by id
- Query by custom dates in UNIX Time
- Implementing an OR statement to wordpress wp_query
- How can i simulate “taxonomy__in” in query?
- Minimize database queries to user tables?
- WP_Query returns more results than expected
- How to make Meta Query case sensitive?
- Populate tax_query terms parameter with post term
- Orderby the sum of several numeric custom meta fields
- unable to retrive parent page information
- Site not getting correct featured image from my query
- Using WP_Query within an mu-plugin
- wp_query ‘s’, search filter with pagination is not working
- Use more than one query, but prevent duplicates – at scale!
- WP Query related posts by tags
- How to add posts, manually, to a wp_query?
- wp_reset_postdata() does not work as expected
- How to display an other custom post type in a different custom post type’s archive?
- Replacing raw database query to WP_Query
- Stale $GLOBALS[‘post’] after custom WP_Query empty result set bothers my template, whose fault is this?
- WP CLI can’t delete plugin related table
- Inserting HTML to close and open divs in WP_Query loops
- How to count posts with specific arguments
- Change query from cat id to slug or name?
- Query only the posts with a post format of “audio”
- Display Current Post’s Position in Custom Taxonomy
- Using Wp_Query without the loop?
- WP Query with multiple tags by get the tags
- Woocommerce pagination and result count after custom loop
- Orderby custom meta returns random order
- Include latest author posts with pagination in single template?
- How to querry for an item that saved in an array?
- Is it possible to add an argument to a custom function added to a filter hook?
- get_post() is not returning correct value
- Order by meta_key doesn’t work
- Update query for wp_posts and wp_postmeta
- How to print term name inside wp post loop
- CPT category post/content is not showing on my page, Please review my coede
- how to get category`s slug in WP_Query loop?
- WP_Query with page_ids in arguments without a result
- Advise on Templates for Custom Queries
- Why is my pagination /page/2 taking me to index.php?
- Creating a query that get all posts but places meta items first
- How to wp_query every Sunday between a startdate and enddate?
- WordPress rewrite with custom parameter doesn’t work
- Why last row deleted when refresh page
- wp_query with meta_query and tax_query
- WordPress live search and filter custom fields
- Meta query orderby meta_value_num sorting by role first
- Avoid removing duplicate posts
- Add to search posts query array with post IDS which will appear first
- Can’t reset the secondary query by wp_reset_postdata()
- Wp_query ordering problem
- Why does the theme insert the comments section if I don’t reset my custom WP_Query?
- Get post Number with local loop and template
- WP_Query tax_query only returning posts that match first term
- Get post related to current post
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- WP query retrieve the src of attached image
- Featured Image as Background with Offset
- custom WP_Query results in showing same posts in all pagination pages
- Problems with WP_Query, Loop, a condition and Posts per Page
- Show recent posts from excluded category
- WordPress meta_query not working
- Create multiple sections for all categories and then queries all the posts for each of those categories
- Using orderby with 2 meta keys
- wp_query – Modify $query to include duplicate content
- $wp_query when new WP_Query
- Query to get all the posts of more than 2 meta_value having same meta_key?
- Unable to pass variable
- WP Query get posts by specific author IDs if one of several logged in authors
- Query specific number of posts for each post type in specific order
- Edit WordPress loop, taxonomies, & filter
- How to display posts from a specific term first then another posts from another terms using tax_query
- Display Featured image from custom post type category (custom taxonomy) wise