Page walk fixes from hailin. fixes #5581

git-svn-id: http://svn.automattic.com/wordpress/trunk@6552 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-01-04 19:55:17 +00:00
parent 1ae1811dd0
commit 91586ebff4
2 changed files with 9 additions and 1 deletions

View File

@ -283,6 +283,14 @@ function page_rows( $pages ) {
$children_pages = array(); $children_pages = array();
foreach ( $pages as $page ) { foreach ( $pages as $page ) {
// catch and repair bad pages
if ( $page->post_parent == $page->ID ) {
$page->post_parent = 0;
$wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_parent = '0' WHERE ID = %d", $page->ID) );
clean_page_cache( $page->ID );
}
if ( 0 == $page->post_parent ) if ( 0 == $page->post_parent )
$top_level_pages[] = $page; $top_level_pages[] = $page;
else else

View File

@ -434,7 +434,7 @@ class Walker {
array_splice( $children_elements, $i, 1 ); array_splice( $children_elements, $i, 1 );
$output = $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output ); $output = $this->display_element( $child, $children_elements, $max_depth, $depth + 1, $args, $output );
$i--; $i = -1;
} }
} }