Arrow down in menu not displaying

Add below code #site-navigation .menu > ul > li.menu-item-has-children > a::after { content: ‘\f107’; font-family: FontAwesome; font-size: 10px; margin-left: 10px; vertical-align: 1px; } #site-navigation .menu > ul > li > ul > li.menu-item-has-children > a::after { color: rgb(34, 34, 34); content: ‘\f105’; font-family: FontAwesome; font-size: 10px; vertical-align: 1px; float: right; } Add 3rd level navigation. … Read more

Custom Walker for Walker_Nav_Menu

Old question, but you can override the </li> in the Walker’s end_el() function (see wp-includes/class-walker-nav-menu.php); in your case, something like: public function end_el( &$output, $item, $depth = 0, $args = array() ) { if ( isset( $args->item_spacing ) && ‘discard’ === $args->item_spacing ) { $n = ”; } else { $n = “\n”; } if … Read more

Why is ‘nav_menu_item_args’ filter’s $item argument empty?

Filters (and actions) need to be declared with the number of arguments accepted by the callback; it is the fourth parameter of add_filter() (default 1): add_filter( ‘nav_menu_item_args’, ‘filter_nav_menu_item_args’, 10, 3 ); function filter_nav_menu_item_args( $args, $item, $depth ) { print_r( $item ); return $args; } See add_filter() for reference.

Extend WordPress REST API to show slugs for menu items

I had the same challenge, and fixed it by adding it to the response. Example: function get_menu() { # Change ‘menu’ to your own navigation slug. $menu_items = wp_get_nav_menu_items(‘menu’); foreach($menu_items as $menu_item) { // ALTERNATIVE: $slug = get_post_field( ‘post_name’, $menu_item->object_id ); $slug = basename( get_permalink($menu_item->object_id) ); $menu_item->slug = $slug; } return $menu_items; } add_action( ‘rest_api_init’, … Read more

Adding custom text in items titles from wp_nav_menu()

The following works, but with the following caveats. It will run for every menu, but it will not run for wp_page_menu, a usuall default callback if a menu can’t be found. Finally, menu items aren’t necessary pages – so you may want to do some logic to check that the menu item you are dealing … Read more

Add “parent” class to parent menu items

This may not be the ideal solution, depending on what you need the class for, but you could add a “parent” class via JavaScript. The line below uses the jQuery :has() selector: $(‘#nav-id’).find(‘li:has(ul)’).addClass(‘parent’);

Search box as a menu item in the nav menu output by wp_nav_menu?

based on : http://wpfirstaid.com/2010/10/extend-the-wordpress-menu/ function wpa_58902($items){ $search=”<li class=”search”>”; $search .= ‘<form method=”get” id=”searchform” action=”https://wordpress.stackexchange.com/”>’; $search .= ‘<label for=”s” class=”assistive-text”>Search</label>’; $search .= ‘<input type=”text” class=”field” name=”s” id=”s” placeholder=”Search” />’; $search .= ‘<input type=”submit” class=”submit” name=”submit” id=”searchsubmit” value=”Search” />’; $search .= ‘</form>’; $search .= ‘</li>’; return $items . $search; } add_filter(‘wp_nav_menu_items’,’wpa_58902′);