I have a menu location defined by a theme, I'd like to change the label from Header Menu to something else (but keeping all it's other settings as is), I can't find any suitable filters to do this within WordPress - is this possible?
I have a menu location defined by a theme, I'd like to change the label from Header Menu to something else (but keeping all it's other settings as is), I can't find any suitable filters to do this within WordPress - is this possible?
Share Improve this question asked Feb 22, 2020 at 10:01 bigdaveygeorgebigdaveygeorge 2074 silver badges12 bronze badges 3- The label is defined by the theme, not by WordPress. – Max Yudin Commented Feb 22, 2020 at 14:38
- Yes, the label is defined by the theme with no filter, therefore the question is whether there are any hooks/filters within WordPress which reads those definitions and to then manipulate the label at that point to give the desired result. @MaxYudin – bigdaveygeorge Commented Feb 22, 2020 at 17:28
- There's no hook for registered menus. – Jacob Peattie Commented Mar 4, 2020 at 1:29
1 Answer
Reset to default 1You are right there is no filter for this, you would have to hack the global instead, in this case $_wp_registered_nav_menus
:
add_action('after_setup_theme', 'custom_menu_location_label');
function custom_menu_location_label() {
global $_wp_registered_nav_menus;
$find = __('Header Menu'); $replace = __('Something Else');
foreach ($_wp_registered_nav_menus as $location => $description) {
if ($find == $description) {
$_wp_registered_nav_menus[$location] = $replace;
}
}
}