سؤال

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?

enter image description here

Thanks.

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top