Opened 3 years ago
Last modified 13 months ago
#13910 new feature request
Get Menu name with wp_nav_menu()
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Priority: | normal | Milestone: | Future Release |
| Component: | Menus | Version: | 3.0 |
| Severity: | normal | Keywords: | has-patch needs-testing dev-feedback |
| Cc: | pavelevap@…, wojtek.szkutnik@…, marko@…, xoodrew@… |
Description
There is no way to get the actual "Menu name" in wp_nav_menu()
For example if you want to create a left sidebar menu you want a header to go with it. In previous versions you could do use wp_list_pages() with "title_li".
With wp_nav_menu() you have to hard code <h3>Static menu name</h3> into the template before calling the function.
If you could get the "Menu name" as defined in backend interface from the wp_nav_menu() it would create the menu title automatically.
Attachments (1)
Change History (8)
wojtek.szkutnik — 3 years ago
comment:3
wojtek.szkutnik — 3 years ago
- Cc wojtek.szkutnik@… added
- Keywords has-patch needs-testing added; wp_nav_menu menu name removed
comment:4
wojtek.szkutnik — 3 years ago
- Keywords gsoc added
comment:6
markoheijnen — 13 months ago
- Cc marko@… added
- Keywords dev-feedback added; gsoc removed
The patch looks wrong. title shouldn't be an argument and it should have been $menu->name.
Also a function like this should be in core
<?
function wp_nav_menu_title( $theme_location ) {
$title = '';
if ( $theme_location && ( $locations = get_nav_menu_locations() ) && isset( $locations[ $theme_location ] ) ) {
$menu = wp_get_nav_menu_object( $locations[ $theme_location ] );
if( $menu && $menu->name ) {
$title = $menu->name;
}
}
return apply_filters( 'wp_nav_menu_title', $title, $theme_location );
}
?>
comment:7
DrewAPicture — 13 months ago
- Cc xoodrew@… added
Note: See
TracTickets for help on using
tickets.

+1 I've needed this a few times, having to resort to a similar solution to http://www.wptavern.com/forum/themes-templates/1563-list-available-wp_nav_menus.html