I’m pretty sure you can use get_pages
(http://codex.wordpress.org/Function_Reference/get_pages) function to solve this. It has child_of
parameter which does exactly what you wanted.
The only problem is that it returns posts and not set $wp_query
, so you can’t use it as loop, but you can always call setup_postdata
and then use template tags as in normal posts loop.
<?php
$mypages = get_pages( array( 'child_of' => <PARENT_PAGE_ID>) );
foreach( $mypages as $page ):
?>
<h2><a href="https://wordpress.stackexchange.com/questions/33194/<?php echo get_page_link( $page->ID ); ?>"><?php echo apply_filters('the_title', $page->post_title); ?></a></h2>
<div class="entry"><?php echo apply_filters( 'the_content', $page->post_content ); ?></div>
<?php endforeach; ?>
Related Posts:
- How to return results of a get_posts() in explicitly defined order
- Modify main WordPress loop with a parse_query filter
- How should I intercept the main query and inject custom join / order by / group by criteria
- Dynamically excluding current page id
- How to order results by date and meta key?
- Static Front-Page Excerpts
- Is it possible to query_posts using post__in and then Loop through them in the ordered they were queried?
- query_posts() ALWAYS displays something?
- How to remove a plugin filter’s priority on specific loops (custom queries)?
- Custom loops, sticky posts, and pagination nightmare
- Filter Loop by Custom Field Value
- Modify loop but keep the original query, what am I doing wrong?
- When to use WordPress loop or Foreach loop?
- Post per page not working if no category specified
- Calling Posts from Specified Cat
- Most Effective Method? Exclude Category and Number of Posts Per Page
- How do I query based on the modified date?
- Script that gets the first tag of post and query all other posts with the same tag
- How to add an “or” instead of and “and” (&) in a WordPress query?
- Modify main loop query for paged and meta key
- Create a Loop with Posts Ordered by Most Recent Comments
- The_content display a different content from a previous loop
- WordPress loop problem: Multiple loops, index.php and is_paged causing duplicate posts on next page
- Including post data in a sidebar occurring outside of and before the Loop
- Multiple loops with / without sticky posts and different post limits
- posts_per_page no limit
- Alternative to query_posts for main loop? [duplicate]
- Query posts by custom taxonomy ID
- Order posts by ID in the given order
- Query posts: how to exclude results if post is in multiple categories
- query_posts ->using meta_compare / where meta value is smaller or greater or equals
- WP 5.8 “Query Loop” block: where to place custom query?
- Pagination on archive.php page
- Best way to load page content in Fancybox popup?
- order post my meta value m/d/y format with year as included value
- Order posts by custom field and if custom field is empty return remaining posts
- _wp_page_template to dynamically use template
- Schedule Sticky Posts
- Post Loop not Returning Permalink
- WordPress – thumbnail image from youtube (function and loop)
- Problem with single-page for my custom post
- How to Display Post View Count
- How to make the list of post and load on same page with sub-pages [closed]
- How to get 4 Posts after the 5 most recent ones
- How would I get 1 latest post from a query for 5 posts?
- post_status => publish not working
- 2 loops on page – one with orderby rand second orderby date
- How do I make archives.php for one category only?
- making random query button using $_GET
- How do I change the default sort order of a custom column on the posts page?
- WordPress pagination showing same posts on each page
- show a post from a specific post format
- 3 Posts in Loop, Show Stickies First
- Order posts by condition
- Search breaks when querying main loop for category
- Authors List page – How to include only those with wp_user_level as Author
- Blog post per page setting conflicting with custom WP_Query?
- Listing all term items alphabetically / sorting loop
- Query posts by meta_key whose value is an array
- Show Blogroll of another WordPress site
- Why this code causes infinite loop?
- Each post is showing twice in my custom query…?
- Wrong post title displayed from loop
- How can I improve the performance of this query_posts loop?
- query_posts() – problem with “s” parameter
- Get the amount of posts on a current page
- How to get posts published on the latest date?
- Problem with different query loops (and “main loop”) on category template page!
- Page title in post query
- Question about querying posts
- How to list most popular post
- How can I query for all children posts regardless of parent
- INSERT in table row fatal error
- Pagination not working on custom query on a page
- WP_Query: Show 10 posts in date order, first three random
- WordPress query reverse order
- How to reverse post navigation at bottom of post
- WP-API: get posts in multiple categories
- Order for custom field after the loop
- Exclude current post ID from loop in sidepbar.php
- Keeping get_posts’ offset and is_paged() synchronized
- Custom Post Type Query W/Category Dropdown
- Having an issue doing a WP_Query with post_content and category__and
- Pagination doesn’t work in query post in tag template
- Assign a class to first element in category in loop
- How to order posts, that have already been filtered by custom taxonomy, by their category names?
- query_posts() doesn’t seem to be called in my page
- Order posts by ACF checkbox
- Why I obtain this WP_Query strange behavior trying to select posts having a specific tag?
- Automatically create a loop for post ID
- Query counting excluded category on paged loop
- query_posts ignores the argument
- The Loop isn’t working
- How to optimize ‘select found_rows()’ query? Several ‘high load average’ alerts daily
- query_posts – slightly more advanced query
- How to go to tag archives using a form
- Resetting a Query using wp_reset_query() or wp_reset_postdata() does not work
- How to exclude certain portfolios from a loop
- Sort posts with multiple meta_keys
- Create “archives by year and week” by category template