Title: get nested pages
Last modified: August 19, 2016

---

# get nested pages

 *  [Patrick Orr](https://wordpress.org/support/users/patrick-orr/)
 * (@patrick-orr)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/get-nested-pages/)
 * Hey all,
    I have been trying to find a way to return page information in order
   to create a landing page. I have done this with posts before to create a blog
   reel and would like to achieve the same overall result with pages with respect
   to parent elements
 * **The Scenario:**
    I use a drop menu with pages created in the wordpress. Nesting
   the pages builds the menu.
 * **The Goal:**
    I would like to get the subpages specific to the parent page. 
   When a user navigates to the parent page I would like it to return links to the
   subpages with some page elements.
 * Here is an example of how I have done this with posts:
    ‘ <?php global $post;
   $myposts = get_posts(‘numberposts=4&offset=news&category_name=news’); foreach(
   $myposts as $post) : setup_postdata($post); ?> <div class=”sidebarpost_newsitem”
   > <div class=”sidebarpost_title”><h5><?php the_title();?></h5></div> <div class
   =”sidebarpost_excerpt”><?php the_excerpt(); ?></div> <div class=”sidebarpost_break”
   ></div> </div> <?php endforeach; ?>’

Viewing 2 replies - 1 through 2 (of 2 total)

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/get-nested-pages/#post-2057193)
 * have you looked into `get_pages()` with the ‘parent’ or ‘child_of’ parameters?
 * [http://codex.wordpress.org/Function_Reference/get_pages](http://codex.wordpress.org/Function_Reference/get_pages)
 *  Thread Starter [Patrick Orr](https://wordpress.org/support/users/patrick-orr/)
 * (@patrick-orr)
 * [15 years, 1 month ago](https://wordpress.org/support/topic/get-nested-pages/#post-2057485)
 * Thanks for the codex, I’ve come across this already and have been fidling with
   this portion:
 *     ```
       <?php
               $mypages = get_pages('child_of='.$post->ID.'&sort_column=post_date&sort_order=desc');
   
               foreach($mypages as $page)
               {
                   $content = $page->post_content;
                   if(!$content) // Check for empty page
                       continue;
   
                   $content = apply_filters('the_content', $content);
               ?>
                   <h2><a href="<?php echo get_page_link($page->ID) ?>"><?php echo $page->post_title ?></a></h2>
                   <div class="entry"><?php echo $content ?></div>
               <?php
               }
           ?>
       ```
   
 * I would like to make it dynamic instead of defining a static page id, is it possible
   to return the children of THIS page?
 * Sorry, I’m more of a html/css guy, php is not my strongest suit.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘get nested pages’ is closed to new replies.

## Tags

 * [php](https://wordpress.org/support/topic-tag/php/)

 * 2 replies
 * 2 participants
 * Last reply from: [Patrick Orr](https://wordpress.org/support/users/patrick-orr/)
 * Last activity: [15 years, 1 month ago](https://wordpress.org/support/topic/get-nested-pages/#post-2057485)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
