How to use wp_nav_menu with hashtag links?

You already hinted it yourself: When you look at wp_get_nav_menu_items() you’ll see that the resulting Array of items gets mapped over with wp_setup_nav_menu_item() – in other words, this function gets applied to each and every nav menu item. In there you can hook into the ‘wp_setup_nav_menu_item’-filter with its $menu_item argument, or use one of the … Read more

Custom Menu not functioning properly

By specifying a theme_location argument in my array, the issue was fixed: wp_nav_menu(array( ‘theme_location’ => ‘main_menu’ )); Edit For a distributed Theme, do not pass the ‘menu’ parameter to the wp_nav_menu() call. It will look for a specific slug of a user-created menu, and will override ‘theme_location’. Only ever pass ‘theme_location’.

Want to add different text after each menu item

You need a Custom Walker for this. In your Custom Walker you define the start of the element different, adding a span after the link: class Walker_With_Title_Menu extends Walker_Nav_Menu { function start_el( &$output, $item, $depth = 0, $args = array(), $id = 0 ) { $output .= sprintf( “\n<li><a href=”https://wordpress.stackexchange.com/questions/131521/%s”%s>%s</a><span class=”your-line”>%s</span></li>\n”, $item->url, ( $item->object_id === … Read more

Add Labels to Admin Menu ( How To )

First of all, searching with wrong keyword won’t give you any right solution. It’s a hint that, you are dealing with Admin menu, and anything under a menu drop down is called a sub menu – so you should search with something like: How to add submenu to any admin menu item + WordPress?. ๐Ÿ™‚ … Read more

Bootstrap button menu on wordpress

The following should setup your menu with the correct classes and IDs applied to your container and ul. The codex entry for wp_nav_menu lists all the possible arguments. wp_nav_menu( array( ‘theme_location’ => ‘primary’, ‘container_class’ => ‘menu-menu-container’, ‘menu_id’ => ‘menu-menu’, ‘menu_class’ => ‘btn-group’ ) ); You can then add the required classes to the menu items … Read more

How to add a element with walker menu right after begin of the navigation tags?

The question is unclear but wp_nav_menu() has a couple of arguments that will allow you to add classes to the output. For example… wp_nav_menu( array( ‘container_class’ => ‘conclass’, ‘menu_class’ => ‘menclass’ ) ); You can alter those arguments using the wp_nav_menu_args filter as well. However, I suspect that when you say “class” you are using … Read more

Wrapping link and .sub-menu with wp_nav_menu

Ifigured it out myself, thanks to reading this: http://code.tutsplus.com/tutorials/understanding-the-walker-class–wp-25401 I created a custom walker: class Child_Wrap extends Walker_Nav_Menu { function end_el(&$output, $item, $depth) { $indent = str_repeat(“\t”, $depth); $output .= “$indent</div></li>\n”; } } And used wp_nav_menu: function main_nav() { wp_nav_menu(array( ‘before’ => ‘<div class=”child-wrap”>’, // before the menu ‘walker’ => new Child_Wrap )); }

Retrieve Menu name for nav_menu_item

The third argument passed to the filter are the $args used for wp_nav_menu: function wpse_147499_nav_menu_css_class( $classes, $item, $args ) { print_r( $args ); exit; } add_filter( ‘nav_menu_css_class’, ‘wpse_147499_nav_menu_css_class’, 10, 3 ); …which gives you: stdClass Object ( [menu] => [container] => [container_class] => [container_id] => [menu_class] => [menu_id] => [echo] => 1 [fallback_cb] => [before] … Read more