From 5fb29643cb135443350e4ac07471a74c40bb8ffe Mon Sep 17 00:00:00 2001 From: ryan Date: Tue, 28 Feb 2006 21:02:10 +0000 Subject: [PATCH] walk_page_tree() fix from Mark J. fixes #2516 git-svn-id: http://svn.automattic.com/wordpress/trunk@3579 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 973417d6d8..5b838b55b5 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -740,7 +740,7 @@ function walk_page_tree($pages, $to_depth, $start_element_callback, $end_element foreach ( $pages as $page ) { if ( !empty($previous_page) && ($page->post_parent == $previous_page->ID) ) { // Previous page is my parent. Descend a level. - array_unshift($parents, $page); + array_unshift($parents, $previous_page); $depth++; if ( !$to_depth || ($depth < $to_depth) ) if ( !empty($start_level_callback) ) { @@ -764,7 +764,7 @@ function walk_page_tree($pages, $to_depth, $start_element_callback, $end_element } } - while ( $parent = array_shift($parents)) { + while ( $parent = array_shift($parents) ) { $depth--; if ( !$to_depth || ($depth < $to_depth) ) { if ( !empty($end_level_callback) ) { @@ -776,7 +776,7 @@ function walk_page_tree($pages, $to_depth, $start_element_callback, $end_element $output = call_user_func_array($end_element_callback, $cb_args); } } - if ( $page->post_parent == $parent->ID ) { + if ( $page->post_parent == $parents[0]->ID ) { break; } }