Someone help me understand why the following do not output anything:

wp_list_pages( 'post_type=post' )
wp_list_pages( 'post_type=event' )

Yet the following work as expected:

wp_list_pages( 'post_type=page' )
WP_Query( 'post_type=post' )
WP_Query( 'post_type=event' )

I'm stumped.


wp_list_pages will only output hierarchical post types. If we look at the function in source, we'll see that it calls get_pages to load pages for output. If we look at get_pages function in source, we'll see:

// Make sure the post type is hierarchical
$hierarchical_post_types = get_post_types( array( 'hierarchical' => true ) );
if ( !in_array( $post_type, $hierarchical_post_types ) )
    return false;

The default post post type is not hierarchical, so the function outputs nothing. If your event post type is also not hierarchical then that would explain why it also outputs nothing.

| improve this answer | |
  • Thanks for the clarification! It's a bummer there's no wp_list_posts() and wp_get_archives() does not include custom post types by default. – Zade Aug 30 '12 at 6:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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