Title: Custom Post Type archive.
Last modified: August 31, 2016

---

# Custom Post Type archive.

 *  [gulliver](https://wordpress.org/support/users/gulliver/)
 * (@gulliver)
 * [10 years ago](https://wordpress.org/support/topic/custom-post-type-archive-5/)
 * I have a hierarchical cpt, all entries for which have children.
 * In a page of a parent, how do I list the children?

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

 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [10 years ago](https://wordpress.org/support/topic/custom-post-type-archive-5/#post-7445266)
 * Use [https://developer.wordpress.org/reference/functions/wp_list_pages/](https://developer.wordpress.org/reference/functions/wp_list_pages/)
 * set the post_type to your CPT and child_of to the current page
 *  Thread Starter [gulliver](https://wordpress.org/support/users/gulliver/)
 * (@gulliver)
 * [10 years ago](https://wordpress.org/support/topic/custom-post-type-archive-5/#post-7445270)
 * Thanks.
 * Struggling to understand this after too many hours staring at a screen, how do
   I ‘set child_of to the current page’?
 * I assume it begins with ‘ ‘child_of’ =>’ but I can’t even guess the rest.
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [10 years ago](https://wordpress.org/support/topic/custom-post-type-archive-5/#post-7445273)
 * there are two possible ways:
 * `$post_id = get_the_ID();`
 * and
 *     ```
       global $post;
       $post_id = $post->ID;
       ```
   
 * Here’s some code for a filter I created that automatically adds the children 
   of a page called “services” after the page’s usual content
 *     ```
       /* for the services page, list children */
   
       function pcs2n_list_children( $content ) {
               global $post;
               if ( is_page( 'services' ) ) {
                       $args = array(
                       'child_of' => $post->ID,
                       'title_li' => '',
                       'echo' => false,
                               );
                                       $content .= wp_list_pages( $args );
               }
   
                       return $content;
       }
       add_filter( 'the_content', 'pcs2n_list_children' );
       ```
   
 *  Thread Starter [gulliver](https://wordpress.org/support/users/gulliver/)
 * (@gulliver)
 * [10 years ago](https://wordpress.org/support/topic/custom-post-type-archive-5/#post-7445405)
 * Thanks.
 * I understand the ‘list children” snippet – and can adapt that to use on various
   pages.
    But I couldn’t adapt it to use on a cpt.
 * I’m clearly failing to understand something which is probably quite straightforward…
   using my existing knowledge I can produce a page which lists all members of a
   cpt, but on a page for one member of that cpt I can’t show a list of children
   of that member.
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [10 years ago](https://wordpress.org/support/topic/custom-post-type-archive-5/#post-7445415)
 * In the above, you’d add ‘post_type’=> get_post_type() and it should list children
   for that particular post.
 *  Thread Starter [gulliver](https://wordpress.org/support/users/gulliver/)
 * (@gulliver)
 * [10 years ago](https://wordpress.org/support/topic/custom-post-type-archive-5/#post-7445419)
 * Steve thanks…
 * Sometimes when looking at forum posts and seeing someone come back for clarification,
   I think ‘Jeez, you have all the clues there – it’s not that difficult.’
 * Finding myself (again) in such a position, I think I should return to this later
   with a clear head… so then, let’s relax with ‘Box of Rain’ and think about anything
   other than WordPress. Maybe I’m just not suited to this. 😉
 *  Moderator [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/)
 * (@sterndata)
 * Volunteer Forum Moderator
 * [10 years ago](https://wordpress.org/support/topic/custom-post-type-archive-5/#post-7445420)
 * Maybe you’ll find direction
    around some corner where it’s been waiting to meet
   you
 *  Thread Starter [gulliver](https://wordpress.org/support/users/gulliver/)
 * (@gulliver)
 * [10 years ago](https://wordpress.org/support/topic/custom-post-type-archive-5/#post-7445421)
 * 😉
    Hopefully, yeah. ‘I will get by… La dee da da da, La da da da da’.
 * Waaaaaaay off topic, I should stop this nonsense.

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

The topic ‘Custom Post Type archive.’ is closed to new replies.

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 8 replies
 * 2 participants
 * Last reply from: [gulliver](https://wordpress.org/support/users/gulliver/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/custom-post-type-archive-5/#post-7445421)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
