WordPress 2.7 “wp_list_pages” Exclude Not Working
I just found out that php template code for wp_list_pages Exlude and Exlude_tree is not working in WordPress 2.7.x
I was having trouble with my menu because of this problem. I tried to search how to fix this. And i found out that it will work if you find this code on wp_includes/post.php:
if ( !empty($exclude_tree) ) {
$exclude = array();
$exclude = (int) $exclude_tree;
$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]);
}
}
now, replace those chunk of code with this one:
if( !empty( $exclude_tree ) )
{
$exclude_trees = array();
$exclude_trees = explode(',', $exclude_tree );
$excludes = array();
foreach( $exclude_trees as $parent_exclude )
{
$excludes[] = $parent_exclude;
$children = get_page_children( $parent_exclude, $pages );
foreach ( $children as $child )
$excludes[] = $child->ID;
}
$total = count( $pages );
for ( $i = 0; $i < $total; $i++ ) {
if ( in_array( $pages[$i]->ID, $excludes) ) {
unset( $pages[$i] );
}
}
}
Thanks for people in this support topic that has helped me found the solution. This is definitely working now.
