Support » Fixing WordPress » 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) )



Viewing 3 replies - 1 through 3 (of 3 total)
  • There’s a bug report and fix for this at

    You might suggest this fix there if you are of the mind. Use your forum login/password there.

    Your fix did resolve the problem at 2.7.1. Looks like it should work at 2.8bleeding.

    [edit yes your fix works at 2.8bleeding]

    Is there any way that I can get this fix to work in 2.9?

    This issue still exists in the get_pages(), but the documentation does not state it will accept multiple page ID’s. But it should!

    Its almost like if you are using the child_of tribute and depth = 1 then it should stay on that level not one up or one down.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘exclude_tree fix for wp_list_pages’ is closed to new replies.