Display posts of custom type in hierarchical order

Part 1

To loops through parent pages and child pages you need a recursive funtion. Luckily goldenapples has written one: https://wordpress.stackexchange.com/a/13678/1878

Part 2

That takes care of that but you still want to be able to order it, so WordPress allows us to set a Page Order. If you go into the edit page screen you will see under the Attributes box a spot for order. You can also set the order in the quick edit screen.
Page Quick Edit Screen

And then we need to tell the loop for orderby that order:

<?php 
$args = array( 
    'post_type'=> 'people',
    'orderby' => 'menu_order',
    'posts_per_page' => -1 );
?>

Leave a Comment