3

I have a custom post type that is set to have hierarchy. I'm trying to create a list of posts in that post type that display's that hierarchy using nested unordered lists. I have this post structure:

Post -child post -- child of child post -- child of child post

And I want to be able to create a list of posts (which i guess are behaving more like pages since they have hierarchy), that reflects this structure using unordered lists, like so:

<ul>
   <li>Post
      <ul>
       <li>child post
           <ul>
           <li>child of child post</li>
           <li>chld of child post</li>
           </ul>
       </li>
     </ul>
   </li>
</ul>

What's the best way to do this (if there is one) so that I don't have to go back into the code whenever I add new parent pages?

5
<ul id="my_cutom_type-list">
    <?php wp_list_pages( 'post_type=my_custom_type&title_li=' ); ?>
</ul>
  • Haha. Wow, I feel stupid. Thanks. I somehow had it in my head that list_pages wouldn't work because they were "post" types and didn't even bother to try it. Thank you!. – Appledore Jun 18 '11 at 3:07
  • Oh wow... hahaha this has taken me so long to find :'D Thanks man! – Matt May 23 '17 at 13:55

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.