Get all generations of page children, not just the first, when using child_of. http://mosquito.wordpress.org/view.php?id=1171

git-svn-id: https://develop.svn.wordpress.org/trunk@2480 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2005-03-27 22:17:23 +00:00
parent 9536835eb4
commit 7413ccfe72
1 changed files with 23 additions and 7 deletions

View File

@ -250,8 +250,27 @@ function the_meta() {
// Pages // Pages
// //
function &get_page_children($page_id, &$pages) {
global $page_cache;
if ( empty($pages) )
$pages = &$page_cache;
$page_list = array();
foreach ($pages as $page) {
if ($page->post_parent == $page_id) {
$page_list[] = $page;
if ( $children = get_page_children($page->ID, $pages)) {
$page_list = array_merge($page_list, $children);
}
}
}
return $page_list;
}
function &get_pages($args = '') { function &get_pages($args = '') {
global $wpdb, $page_cache; global $wpdb;
parse_str($args, $r); parse_str($args, $r);
@ -269,15 +288,9 @@ function &get_pages($args = '') {
} }
} }
$post_parent = '';
if ($r['child_of']) {
$post_parent = ' AND post_parent=' . $r['child_of'] . ' ';
}
$pages = $wpdb->get_results("SELECT * " . $pages = $wpdb->get_results("SELECT * " .
"FROM $wpdb->posts " . "FROM $wpdb->posts " .
"WHERE post_status = 'static' " . "WHERE post_status = 'static' " .
"$post_parent" .
"$exclusions " . "$exclusions " .
"ORDER BY " . $r['sort_column'] . " " . $r['sort_order']); "ORDER BY " . $r['sort_column'] . " " . $r['sort_order']);
@ -287,6 +300,9 @@ function &get_pages($args = '') {
// Update cache. // Update cache.
update_page_cache($pages); update_page_cache($pages);
if ($r['child_of'])
$pages = & get_page_children($r['child_of'], $pages);
return $pages; return $pages;
} }