#24249 closed enhancement (duplicate)
wp_page_menu with exclude_tree
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | Priority: | normal | |
| Severity: | normal | Version: | |
| Component: | Template | Keywords: | |
| Focuses: | Cc: |
Description
The param exlude_tree doesn't work with wp_page_menu.
The issue in wp-includes/post.php
line 3816
replace
if ( !empty($exclude_tree) ) {
$exclude = (int) $exclude_tree;
$children = get_page_children($exclude, $pages);
$excludes = array();
foreach ( $children as $child )
$excludes[] = $child->ID;
$excludes[] = $exclude;
$num_pages = count($pages);
for ( $i = 0; $i < $num_pages; $i++ ) {
if ( in_array($pages[$i]->ID, $excludes) )
unset($pages[$i]);
}
}
by
if ( !empty($exclude_tree) ) {
$list_exclude = explode(",",$exclude_tree);
$excludes = array();
foreach ($list_exclude as $exclude)
{
$exclude = (int)$exclude;
$children = get_page_children($exclude, $pages);
foreach ( $children as $child )
$excludes[] = $child->ID;
$excludes[] = $exclude;
}
$num_pages = count($pages);
for ( $i = 0; $i < $num_pages; $i++ ) {
if ( in_array($pages[$i]->ID, $excludes) )
unset($pages[$i]);
}
}
Tested and it works with wordpress 3.5.1
Thanks
Change History (2)
Note: See
TracTickets for help on using
tickets.
Looks like your suggestion is to handle multiple values in
exclude_tree, so this is a duplicate of #9153 (also #16202 and #19478).