I am currently working on creating an events section for a website. My original plan was to create a custom post type for Events and create a new post for each event. Then I would query the top five events on the home page. My problem is that I need to have sub pages/posts for each event. These pages/posts will need to show up in a sidebar when the single event post is viewed. Is that possible?

Can I create a parent/child relationship with each event post and its sub posts or would it be better to use custom taxonomies to organize this information? The site will be client updated, so I need to create a system that is straightforward and sustainable with a logical permalink structure.

Any help would be greatly appreciated. Thanks!

1 Answer 1


when you create a custom post type, and make it hierarchical, it will behave like pages. so you can have sub events the same way you have sub pages.

look at register_post_type function arguments here : http://codex.wordpress.org/Function_Reference/register_post_type#Arguments

then use wp_list_pages function to list subpages. see : http://codex.wordpress.org/Function_Reference/wp_list_pages#List_members_of_a_custom_post_type

something like this (not tested) :

$args = array(
  'title_li'  => '',
  'child_of'  => $post->ID,
  'post_type' => 'event',
  'title_li'  => __('Sub events'),
  'echo'      => 0,
$children = wp_list_pages( $args );
if ( $children ) {
    <?php echo $children ?>
<?php } ?>

please, see this topic on the WordPress forum also.

all you need seems to be in the codex. do not hesitate to follow its rules. here you will find nearly all the tools you wish : http://codex.wordpress.org/Function_Reference/


  • I have created a hierarchical custom post type called Events and it is working great. I am now able to list sub-posts for each event in a sidebar using wp_list_pages as you suggested. My only problem is that I cannot figure out how to highlight the current post in the menu. I am used to using .current_page_item, but this does not seem to apply to custom posts. Any suggestions would be appreciated!
    – Susan
    Jan 2, 2012 at 14:58
  • sorry, i recieved no warning for your next question... it seems that you are right. the current_page_item is not displayed :( i've modified the code a bit so you may try this instead : <?php $args = array( 'child_of' => array_pop( get_post_ancestors( $post->ID ) ), 'post_type' => 'event', 'title_li' => __('Sub events'), 'echo' => 0, ); $children = preg_replace( '/page-item-' . $post->ID . '/', 'current_page_item page-item-' . $post->ID, wp_list_pages( $args ) ); if ( $children ) { ?> <ul> <?php echo $children ?> </ul> <?php } ?> Jan 9, 2012 at 18:35
  • arg ! this is ugly ! i've made 2 changes : replace $children = wp_list_pages( $args ); with $children = preg_replace( '/page-item-' . $post->ID . '/', 'current_page_item page-item-' . $post->ID, wp_list_pages( $args ) ); Jan 9, 2012 at 18:43
  • and 'child_of' => $post->ID, with 'child_of' => array_pop( get_post_ancestors( $post->ID ) ), so the menu will work in your sub events showing the top level ancestors with all childs. Jan 9, 2012 at 18:46
  • Or even, remove the chil_of parameter so you will have the complete tree :) Well it depends on what you want to display.... Jan 9, 2012 at 18:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.