I have a set of custom post types with the capability_type
argument set to 'page'
I want to include these in wp_list_pages()
or similar so I can use the dynamic classes (such as .current_page_item
and the like).
I’ve read this post but I’m not sure it’s exactly what I’m looking for, can anyone help me out with a code sample / more in-depth explanation.
The
wp_list_pages()
function callsget_pages()
, which can’t be easily overridden with a different post type. Here’s a basic modification of that function which callsget_posts()
instead. This takes basically the same arguments as wp_list_pages, with one additional: *post_type* (set as the name of your post type).Note: its mostly copy-pasted from source. There’s certainly a few arguments left in there that aren’t doing anything and there might well be some use cases I haven’t thought of that would break it. It works, surprisingly, though, with both hierarchical and non-hierarchical post types, though…
@goldenapples:
Excellent post! I was searching for this and got here. One thing I noticed is the orderby was not working properly, and got it fixed by adding the following line to the default arguments:
Thanks,
Camilo