I am using a child_of loop within my page loop to add the child pages to a drop down list. But within the child_of loop, I need to find what level it is at, or how many parents it has. This is my code:
<?php foreach(get_pages('sort_column=menu_order&parent=0') as $page) { ?>
<li class="page_item page-item-<?php echo $page -> ID; ?><?php if($_GET['page_id'] == $page -> ID) { echo ' current_page_item'; } ?>">
<a href="<?php echo bloginfo('url') . "/?page_id=" . $page -> ID; ?>">
<?php echo $page -> post_title; ?>
</a>
<?php if(get_pages('child_of='.$page->ID)) { ?>
<ul class="<?php echo $page -> ID; ?> child">
<?php foreach(get_pages('child_of='.$page->ID) as $child) { ?>
<li class="page_item page-item-<?php echo $child -> ID; ?><?php if($_GET['page_id'] == $child -> ID) { echo ' current_page_item'; } ?>">
<a href="<?php echo bloginfo('url') . "/?page_id=" . $child -> ID; ?>">
<?php echo $child -> post_title; ?>
</a>
</li>
<?php } ?>
</ul>
<?php } ?>
</li>
<?php } ?>
within the second foreach loop, I need to find what hierarchy level the $child is at.