问题
I am trying to edit my header.php to call the navigation label of a page as opposed to the page title. Here is the existing code...
<title><?php wp_title( '' ); ?></title>
What is the code for calling or echoing the navigation label of a menu item?
Thanks.
回答1:
What you need is to access the wp_nav_menu_objects
, by first rendering the menu to extract the label in order to use it on the page title
.
You can see a working solution well explained on this links:
How to get current-menu-item title as variable?
first render the menu and then display it later
来源:https://stackoverflow.com/questions/10865920/wordpress-navigation-label-in-browser-tab