List posts from Custom Post type with hierarchy?

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

Read More

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?

Related posts

Leave a Reply

1 comment