Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

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.

share|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

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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