WordPress.org

Make WordPress Core

Opened 12 months ago

Closed 12 months ago

Last modified 12 months ago

#24249 closed enhancement (duplicate)

wp_page_menu with exclude_tree

Reported by: mike_adaka 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)

comment:1 SergeyBiryukov12 months ago

  • Component changed from General to Template
  • Milestone Awaiting Review deleted
  • Status changed from new to closed

Looks like your suggestion is to handle multiple values in exclude_tree, so this is a duplicate of #9153 (also #16202 and #19478).

comment:2 SergeyBiryukov12 months ago

  • Resolution set to duplicate
  • Type changed from defect (bug) to enhancement
Note: See TracTickets for help on using tickets.