WordPress.org

Make WordPress Core

Opened 4 years ago

Last modified 8 months ago

#13910 new feature request

Get Menu name with wp_nav_menu()

Reported by: jowo Owned by:
Milestone: Future Release Priority: normal
Severity: normal Version: 3.0
Component: Menus Keywords: has-patch needs-testing dev-feedback
Focuses: Cc:

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)

13910.diff (1.2 KB) - added by wojtek.szkutnik 4 years ago.

Download all attachments as: .zip

Change History (15)

comment:1 ocean904 years ago

  • Milestone changed from 3.0 to Future Release

comment:2 pavelevap4 years ago

  • Cc pavelevap@… added

wojtek.szkutnik4 years ago

comment:3 wojtek.szkutnik4 years ago

  • Cc wojtek.szkutnik@… added
  • Keywords has-patch needs-testing added; wp_nav_menu menu name removed

comment:4 wojtek.szkutnik4 years ago

  • Keywords gsoc added

comment:5 dangayle3 years ago

+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

comment:6 markoheijnen2 years 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 DrewAPicture2 years ago

  • Cc xoodrew@… added

comment:8 togelini8 months ago

Nothing.

Last edited 8 months ago by helen (previous) (diff)

comment:9 togelini8 months ago

Nothing.

Last edited 8 months ago by helen (previous) (diff)

comment:10 togelini8 months ago

Nothing

Last edited 8 months ago by ocean90 (previous) (diff)

comment:11 togelini8 months ago

Nothing.

Last edited 8 months ago by ocean90 (previous) (diff)

comment:12 togelini8 months ago

Nothing.

Last edited 8 months ago by ocean90 (previous) (diff)

comment:13 togelini8 months ago

Nothing.

Last edited 8 months ago by ocean90 (previous) (diff)

comment:14 togelini8 months ago

yg ini satu lagi buat refrensi anda mungkin dapat dijadikan artikulasi http://bekatak.com disana dapat anda lihat cucak rowonya....

Version 0, edited 8 months ago by togelini (next)
Note: See TracTickets for help on using tickets.