sarthemaker
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Themes and Templates
In reply to: Get page hierarchyI figured it out, I used an array $hierarchy and set:
$hierarchy[$page -> ID] = 0; $hierarchy[$child -> ID] = $hierarchy[$child -> post_parent] + 1;this stored the hierarchy of each page for later use.
Forum: Themes and Templates
In reply to: Get page hierarchyI 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.
Viewing 2 replies - 1 through 2 (of 2 total)