Title: Loop Through Child Pages
Last modified: August 20, 2016

---

# Loop Through Child Pages

 *  [foochuck](https://wordpress.org/support/users/foochuck/)
 * (@foochuck)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/loop-through-child-pages/)
 * I’m trying to create a loop within a page template that looks for the current
   page’s child pages and pulls in the following:
 * -featured image on each child page
    -custom field from child page -permalink 
   to child page
 * Is there a specific function in WP that can get me started with a loop like this?
 * Thanks!

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

 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/loop-through-child-pages/#post-2189368)
 * get_pages
    [http://codex.wordpress.org/Function_Reference/get_pages](http://codex.wordpress.org/Function_Reference/get_pages)
 * get_the_post_thumbnail()
    [http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail](http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail)
 * get_post_meta()
    [http://codex.wordpress.org/Function_Reference/get_post_meta](http://codex.wordpress.org/Function_Reference/get_post_meta)
 * get_permalink()
    [http://codex.wordpress.org/Function_Reference/get_permalink](http://codex.wordpress.org/Function_Reference/get_permalink)
 *  Thread Starter [foochuck](https://wordpress.org/support/users/foochuck/)
 * (@foochuck)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/loop-through-child-pages/#post-2189407)
 * I found this solution:
 *     ```
       <?php query_posts(array('showposts' => 20, 'post_parent' => 7, 'post_type' => 'page')); while (have_posts()) { the_post(); ?>
   
       <h2><?php the_title(); ?></h2>
   
       <?php } ?>
       ```
   
 * However, how would I set post_parent to be the current page that’s using the 
   template, instead of explicitly defining a page ID?
 *  [Michael](https://wordpress.org/support/users/alchymyth/)
 * (@alchymyth)
 * [14 years, 10 months ago](https://wordpress.org/support/topic/loop-through-child-pages/#post-2189413)
 * the current page id is usually:
 * `$current_page_id = $post->ID;`

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

The topic ‘Loop Through Child Pages’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 3 replies
 * 2 participants
 * Last reply from: [Michael](https://wordpress.org/support/users/alchymyth/)
 * Last activity: [14 years, 10 months ago](https://wordpress.org/support/topic/loop-through-child-pages/#post-2189413)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
