conditional menu with custom fields

This can be done by registering different menu location for different users and then update location according to the User type which user selected during the registration time. We need to add the given code to functions.php file of the theme. In this code we are registering custom menus. function custom_menus_registration() { register_nav_menus( array( ‘user_type_a_menu’ … Read more

How to get the navigation menu items? [closed]

To get a full control of the menu items you can create a custom Walker class, which extends the default Walker_Nav_Menu class. Override and customize the class methods as needed. Finally pass an instance of the custom walker to wp_nav_menu( array $args = array() ) with walker key in the $args array. If you only … Read more

How to highlight blog page menu item for blog posts?

To ensure the “Journal” menu item is highlighted for single posts without adding individual posts as sub-items in the menu, you can use a WordPress filter and some custom CSS or JavaScript. Here’s a solution that involves adding a bit of PHP to your theme’s functions.php file to modify the menu classes. Step 1: Add … Read more

Primary menu item is not highlighting when page is active even though it is linked from a url with query string to pre-populate a form field

I checked both of your links and in the <body> tag, both of them have class page-id-1508, meaning that the page id is recognised correctly either with or without the query variable. However, as @mmm suggested in the comment above, it seems that you added the menu item as Custom Link (note the menu item … Read more

Managing menus in “The Store” theme [closed]

You have the same menu assigned to both locations. In order to decouple them you need to deselect “menu-principal” from the Top Menu location. It’s possible the theme may try to automatically populate a location when no menu is assigned. If this is the case, create a new menu with no items and assign it.

Only display nav menu if it is populated with menu items?

This solution was shared by @TheDeadMedic over here… $menu_exists_and_has_items = wp_nav_menu( array( ‘theme_location’ => ‘example-menu-location’, ‘container_class’ => ‘example-menu-container’, ‘menu_class’ => ‘example-menu-class’, ‘fallback_cb’ => false, ‘echo’ => false ) ); if ( $menu_exists_and_has_items ) { … Importantly, note that the menu is not echoed in the initial array saved to PHP variable…

How do I have WordPress use the tag for generated menus?

If you’re just trying to replace <ul…> and </ul> with <menu…> and </menu> in the generated HTML, you can use the wp_nav_menu filter: add_filter( ‘wp_nav_menu’, ‘wpse_426932_menu_fix’ ); /** * Fixes the menu HTML to use <menu> instead of <ul>. * * @param string $html The menu HTML. * @return string The fixed menu HTML. */ … Read more

tech