exclude_tree fix for wp_list_pages
-
While “exclude_tree” has been added to the documentation, it doesn’t perform as documented (2.7.0). It only accepts the first ID in the list and ignores additional ones. To correct this I added the following to post.php in the /wp-includes folder @line 2185:
if ( !empty($exclude_tree) ) {
$excludetrees = array();
$excludetrees = preg_split(‘/[\s,]+/’,$exclude_tree);
// $exclude = (int) $exclude_tree;
foreach ($excludetrees as $exclude) { $children = get_page_children($exclude, $pages);
$excludes = array();
foreach ( $children as $child )
$excludes[] = $child->ID;
$excludes[] = $exclude;
$total = count($pages);
for ( $i = 0; $i < $total; $i++ ) {
if ( in_array($pages[$i]->ID, $excludes) )
unset($pages[$i]);
}
}
}Thanks,
Rasmataz
The topic ‘exclude_tree fix for wp_list_pages’ is closed to new replies.