How to give custom classes to the WordPress Menu widget

(Updated based on comments below.) <div class=”menu-menu-1-container”> is coming from WP’s default menu container. You can customize what tag is used (div, ul, etc.) or tell WP not to use a container at all, as well as set the ID and/or class (menu-menu-1-container, etc.) by using the container, container_class and container_id arguments when you call … Read more

How to add a submenu toggle button inside all “li” elements that have a submenu?

I managed to solve this: Create the function So I created a new custom walker function in functions.php and copied all the code of the core wp nav walker function (wp-includes/class-walker-nav-menu.php). Check for a menu item that has children I then added this array_search in public function start_el to check if the parent element has … Read more

Editing WordPress Nav Menu Walker

You need create additional field for menu item. Because if you will use class field – you will block adding additional class to links. But if it’s ok – create <i class=”$your_class”></i> before link title. And @Dilip Gupta gave solution to you.

Variables within wp_nav_menu

wp_nav_menu() is irrelevant here. An Array is an Array regardless. But no, this won’t work. It will result in array that looks like this: array( ‘theme_location’ => ‘right’, array( ‘container’ => false, ‘menu_class’ => false, ‘items_wrap’ => ‘%3$s’ // Removes <ul> and wraps <li> ), ) To get the values in a single array you … Read more

WordPress sub-menu items suddenly not showing

Welcome, Submenus are there. There is theme css on line 77 of style.css hiding the submenu. To explore, Use something like FireFoxs ‘inspect element’ and untick the display: none. Take up with theme provider as to whether this is a bug (should show on hover), or intentional. Also explore whether some plugin or other css … Read more

Make menu bootstrap compatible

You can try this way: <nav class=”navbar navbar-default” role=”navigation”> <div class=”container”> <div class=”navbar-header”> <button type=”button” class=”navbar-toggle collapsed” data-toggle=”collapse” data-target=”#navbar” aria-expanded=”false” aria-controls=”navbar”> <span class=”sr-only”>Toggle navigation</span> <span class=”icon-bar top-bar”></span> <span class=”icon-bar middle-bar”></span> <span class=”icon-bar bottom-bar”></span> </button> <a class=”navbar-brand” href=”https://wordpress.stackexchange.com/questions/313884/<?php coldstar_the_page_link(“front-page.php’ ); ?>”> <img src=”<?php bloginfo(‘template_url’); ?>/images/companylogo.png” class=”img-responsive hidden-md” alt=”Bed Centre Grimsby Logo”> <img src=”<?php bloginfo(‘template_url’); ?>/images/logo.png” class=”img-responsive … Read more

Third level navigation class

You don’t need to write your custom Walker for that… Let’s take a look on built-in Walker_Nav_Menu. You’ll find this function: public function start_lvl( &$output, $depth = 0, $args = array() ) { if ( isset( $args->item_spacing ) && ‘discard’ === $args->item_spacing ) { $t=””; $n = ”; } else { $t = “\t”; $n … Read more

Hide menu item based on user’s custom capability

This plugin provides filter to manage the menu item by meta value: function custom_menu_item_visibility( $visible, $item ){ if( isset( $item->roles ) ){ $user_id = get_current_user_id(); $user_meta = get_user_meta( $user_id, ‘your-meta-key’, true ); if ( /* your condition */ ){ $visible = true; } else { $visible = false; } } return $visible; } add_filter( ‘nav_menu_roles_item_visibility’, … Read more