Echo Menu located in primary navigation

You can use wp_get_nav_menu_items https://developer.wordpress.org/reference/functions/wp_get_nav_menu_items/ function to get your menu items in the form of an array , you can pass any of Menu ID, slug, name, or object in wp_get_nav_menu_items function. $locations = get_nav_menu_locations(); $main_menu = wp_get_nav_menu_items($locations[‘primary’]); print_r($main_menu);

How are methods of class Walker_Nav_Menu invoked?

In short, wp_nav_menu() calls upon the walk_nav_menu_tree() function and passes along the processed arguments (including the Walker_Nav_Menu instance to use, if provided). walk_nav_menu_tree() invokes the the Walker_Nav_Menu::walk() method on the provided instance or on a new instance of the default Walker_Nav_Menu class if none was provided. Walker_Nav_Menu::walk() iterates through nav menu items and contextually calls … Read more

Adding conditional classes to wp_get_nav_menu_items

Hello just posting that I have found a solution for this using <?php $menu_name=”main-menu”; $menuitems = wp_get_nav_menu_items($menu_name); foreach ($menuitems as $item ) { $active_link = ( $item->object_id == get_queried_object_id() ) ? ‘current’ : ”; if (!$active_link) { echo ‘<a class=”dn dib-ns poppins f7 white hover-gold ml3 ml4-l header-navigation__link-item” href=”‘.$item->url.'”>’.$item->title.'</a>’; } else { echo ‘<a class=”dn … Read more

Custom theme – pages in menu

Since version 3.0 WordPress includes new menu system. It allows to setup menu items in administration area easily and associate menus with specific places in theme templates. It outputs decent list-based markup (pre-filled with classes) that you can style with CSS (and customize if needed). See Navigation Menus for where to start.