3

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?

4

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

$args = array(
    'post_type'=>'gallery'
);
wp_list_pages( $args ); 
  • 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

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.