My current idea is:
- Use
get_pagesto get all of the descendants of TOP and put the IDs in an arrayarrayAll. - Then run
get_pagesagain withparent=1to get just the direct children of TOP. Put these in arrayarrayChildren. - Run in php
arrayGrandchildren = array_diff(arrayAll, arrayChildren)to get a list of all pages from the first array (which contains all descendants of TOP) that do not include the direct children. - In
WP_Query, set ‘post_in=arrayGrandchildren&order=rand‘ to get random posts from the list of grandchildren.
Related Posts:
- Set order of returned items in the WP_Query() class/function
- Search pages that are a child of the current page
- Exclude parent with child pages from WP_Query
- When listing child pages run out of memory
- Get a page ancestor from a most viewed list
- wp query to get child pages of current page
- Page template query with WP_Query
- How to display page content in a page template?
- Does WordPress generate an automatic page for post formats?
- Single page theme that uses pages for the content
- Trying to list out child pages with WP_Query
- Order by menu structure
- Targeting specific pages in the loop
- What are the differences between “Latest Posts” and “Static Page”?
- List the 5 most recent child pages
- WP_Query not retrieving by random order under parent
- Set if condition with wp_nav_menu
- Pagination of a WP_Query Loop in a child-page page template
- Need wp_query to return all children and grandchildren
- How to get all child pages in their parent page?
- How to display summary content from a Page (Not a Post) on another page
- Serve specific “template” page at any URL that ends in its slug
- Display custom tags on pages that have a specific page parent
- Is there a reason why Pages are not publicly_queryable?
- Why post__not_in is ignored?
- Get Child Page IDs by Parent ID
- How to Create a Random List of Child Pages
- complex get_posts() query to select child pages
- Create a loop on my pages with new “WP_Query”
- All blog data on a page using custom query gives 404 for page 2 and onward
- How to Display Shortcode in the correct location, currently displaying before content after Page Title?
- WP_Query returns different results from get_posts() [closed]
- WPQuery calling specific posts problem
- WP_Query with multiple orderby NOT working with ASC and DESC, what’s wrong?
- Display specific page (that is child) content on parent page
- Get query results with a page title
- wp-query, pull children of parent page
- How to get current page nearest parent id?
- How to get main menu only with wp_nav_menu
- Unable to paginate a custom page query
- How to create single page site in WordPress
- Determine if ID is page or post and query the ID
- How to query for a page, get data, then query for child pages of that page
- Custom query does not find pages
- How to get pages of parent (non-recursive)?
- WP Query and multiple pages
- How to use custom page for all posts with custom url, call another directory?
- Show child by slug, while knowing parent ID
- display the children of the post using the current page as the main parent
- pages shortcode filtering by category
- Paginate nested query of child posts
- How to create page that lists tags by initial letter?
- WP_Query doesn’t return some child pages even though the database shows them
- How can I use a specific wordpress page template if certain words are used in page title [closed]
- Category Archive not working for pages
- Retrieving category pages from subcategory returns empty sets
- Issue in If else condition [closed]
- Show parent’s child and also child’s, child on a page?
- List of child pages fetch next results at link click
- get contents and permalink from a specified page
- Hierarchical List Pages as a table
- Get Child Custom Post Content on Single.php?
- Get next post when using pagination with WP_Query?
- How to get child pages and add unique class only to active page?
- WordPress pagination returns the same posts
- How to write short code with if else to get page_id?
- Rewrite URL custom search query
- Paginate_Links page 2 doesn’t work
- Create a “Dummy” parent page for a hierarchy in page listing?
- WordPress 4.9.5 PHP intermittent warning trim() expects parameter 1 to be string, array given
- Merging multiple wp_query objects
- Query causing load because of SQL_CALC_FOUND_ROWS post counting?
- Using custom meta_query with relation not working as expected
- Nested query inside Logical operator OR not working in meta_query
- SQL Statement generated by WP_Query not producing expected results
- Only show first post to match certain criteria within WP_Query
- Best practice for multiple queries on page
- How to order a post type with meta_value_num and if meta_value_num does not exist then order by date
- Exclude post on loop by multiple meta key value
- How to find out what “Blog pages show at most” is set to [duplicate]
- difference between $wp_the_query and $wp_query? & getting the values properly [duplicate]
- Ignore/Skip default value on orderby menu_order?
- WP_Query order by date in meta_value
- WP_Query pagination not working in admin area
- Custom Field sort not working (WP 3.8.1)
- Get post ID’s from one query and exclude from another
- WordPress Query is taking more then 20 second and stuck on creating index
- Modifying raw $_POST data early in the lifecycle
- Meta query with order by another custom field
- Get the Plugin Which Triggered a MySql Query in WordPress?
- Difficulty with rewrite rules
- Show selected images on top in Media Manager
- How to limit WP_Query to one result on the loop?
- WP User Query get all authors with last name starting with specific letter
- WordPress pages with hierarchy
- Is there a way to include a post multiple times in the same query result?
- showing all search result in one template
- WP Query Args – Title or Taxonomy Value
- WordPress – Optimize the Meta Query for 3 meta keys at a time
- How to `’orderby’ => ‘meta_value_num’` in a series of orderby parameters