Tell me more ×
WordPress Answers is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is there a way to display the name of a custom menu in the frontend? I can't use the widget title because of the usage of many languages.

share|improve this question

migrated from stackoverflow.com Nov 4 '11 at 15:13

1 Answer

Yes, you can display the name of custom menu in the frontend. All you need to know is the menu location identifier. This is the same id which is used in register_nav_menu() function.

Here is the code:

<?php

$menu_location = 'primary';
$menu_locations = get_nav_menu_locations();
$menu_object = (isset($menu_locations[$menu_location]) ? wp_get_nav_menu_object($menu_locations[$menu_location]) : null);
$menu_name = (isset($menu_object->name) ? $menu_object->name : '');

echo esc_html($menu_name);
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.