WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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:




What technique should I be using here?

share|improve this question
up vote 3 down vote accepted

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

$args = array(
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
@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


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.