WordPress.org

Ready to get started?Download WordPress

Forums

exclude_tree fix for wp_list_pages (4 posts)

  1. Rasmataz
    Member
    Posted 5 years ago #

    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

  2. MichaelH
    Member
    Posted 5 years ago #

    There's a bug report and fix for this at https://core.trac.wordpress.org/ticket/9153

    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]

  3. JaredPenner
    Member
    Posted 4 years ago #

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

  4. adampatterson
    Member
    Posted 4 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.