[wp-trac] [WordPress Trac] #15777: Add a filter to allow a menu item to be manually selected
WordPress Trac
noreply at wordpress.org
Thu Jan 24 10:39:29 UTC 2013
#15777: Add a filter to allow a menu item to be manually selected
------------------------------------------------+--------------------------
Reporter: aaroncampbell | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Future
Component: Menus | Release
Severity: normal | Version: 3.0
Keywords: dev-feedback 3.2-early needs-patch | Resolution:
------------------------------------------------+--------------------------
Changes (by kovshenin):
* cc: kovshenin (added)
Comment:
I think we should close this. Navigation menus are already filterable in
many many places, including `wp_nav_menu_items` and `wp_nav_menu_objects`.
Here's an example how one would always highlight Glossary in their menu:
{{{
function my_wp_nav_menu_objects( $menu_items, $args ) {
foreach ( $menu_items as $item )
if ( $item->post_name == 'glossary' )
$item->classes[] = 'current-menu-item';
return $menu_items;
}
add_filter( 'wp_nav_menu_objects', 'my_wp_nav_menu_objects', 10, 2 );
}}}
Add a condition to that (`is_tag` or `is_tax`) and you've solved your
problem.
--
Ticket URL: <http://core.trac.wordpress.org/ticket/15777#comment:5>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list