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.

In a theme I'm building, there are two main types of page. One is a product-gallery, one is for general info. I'd like to use wp_get_pages() or wp_list_pages() twice in the sidebar, one with a list of one type of page, and one with the other.

I don't want to hard-code include or exclude in either list, as I can't predict which page IDs will be which type of page. So I'd like to do something like:

wp_list_pages('type=gallery')

and

wp_list_pages('type=page')

What technique should I be using here?

share|improve this question

1 Answer 1

up vote 3 down vote accepted

Create a hierarchical custom post type, then pass post_type to wp_list_pages:

$args = array(
    'post_type'=>'gallery'
);
wp_list_pages( $args ); 
share|improve this answer
    
Is it possible somehow to have post_type argument to include wp native pages and all hierarchical Custom Post Types, that are added dynamically - meaning that I won't know their names, but know that they are added dynamically. Thanks! –  dashaluna Nov 9 '11 at 9:58
1  
@dashaluna - you can get all registered post types via get_post_types‌​,but as far as I know, the post_type argument of wp_list_pages can only be a single post type, not an array of types. you could use WP_Query instead though, which accepts an array of post types. –  Milo Nov 9 '11 at 18:17
    
@ Milo, thank you –  dashaluna Nov 22 '11 at 12:54

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.