You can easily add any HTML element to all menu items that have children by extending the Walker_Nav_Menu core class. The code below will add <i>
icon element just after menu item </a>
tag but you can of course change that if you need them inside or somewhere else by changing the $item_output
variable.
function yourprefix_menu_arrow($item_output, $item, $depth, $args) {
if (in_array('menu-item-has-children', $item->classes)) {
$arrow = '<i class="fa fa-angle-down"></i>'; // Change the class to your font icon
$item_output = str_replace('</a>', '</a>'. $arrow .'', $item_output);
}
return $item_output;
}
add_filter('walker_nav_menu_start_el', 'yourprefix_menu_arrow', 10, 4);
Cheers!
Related Posts:
- Adding toggle-able element after menu item
- Multi Level Bootstrap Navigation Menu in WordPress
- Show only 2nd level of navigation depending on active navigation
- Custom Nav Walker sub-menu HTML construct
- Adding different classes to anchor in navigation menu
- how to automatically generate hierarchical menus from hierarchy of pages?
- Add class to menu ul with active child
- How to display dynamic content in start_lvl function
- Menus like a CMS
- How to have custom menu Item CSS Classes for wp_page_menu() or wp_list_pages()
- How to add a submenu toggle button inside all “li” elements that have a submenu?
- Check if menu id = $specific_id – then insert specific
- wp_nav_menu() with multiple Class
- Trying to Create Menu in WordPress
- How do I add recent posts to the menu?
- Hierarchical menu nesting problem with jQuery targetting
- Automatically list top level menu item child pages
- Check if menu_item has children or has parent
- Add a submenu to wp_nav_menu
- How to buid wordpress menu with auto width sub-menu items in dropdown menu without any items sharing one line [closed]
- Twenty Fifteen: Change navigation menu behavior
- How to Add support for sub-menu item description in wordpress?
- WP Menu Rollover Nav Item and Effect DIV Elsewhere
- Add Different Class on Different Ul in twenty-twentyone theme
- wp_nav_menu container style args
- Bootstrap Theme Migrated to WordPress
- WordPress + Bootstrap: Replace primary navigation menu on mobile?
- How can I click the parent menu then redirect to a special URL?
- Creating navigation out of specific IDs and their children?
- Where to place a svg chevron down in my custom walker?
- Add href to tag in nav menu for mobile
- Links in new menu don’t work
- Conditional Nav Menu Inside Nav Menu Across Multisite Sites
- Show Child of Parent Page including all other parents
- nav_menu: how to force a subpage switching on the parent menu
- How was this menu system created?
- Display sub menus as separate lists
- Give custom class names to WP nav sub-menu
- Nav walker bootstrap: Display 3rd level and 4th level in dropdown menu
- wp_nav_menu parent in submenu
- How to modify navigation menu of the “My Account” page in WooCommerce
- Show current navigation path from menu
- Exclude one item from wp_list_pages( $args );
- Put a wp_nav_menu inside another one
- Add class to active top level (grandparent) menu item
- Generate a Menu that displays all child pages of top level parent
- Check if wp_nav_menu items have submenus
- How to get Menu Navigation Labels to output HTML
- custom menu not found
- wp_nav_menu doesn’t generate parent/ancestor classes
- How to add text before WordPress menu item href
- Nav walker, bootstrap: Display 3rd level items under 2nd level
- Programmatically adding menu items function replicates in multiple menus
- Benefits of using Nav Walker?
- Use walker for specific menu, or avoid use of walker
- Change where navigation bar links?
- has_children in custom nav_walker
- How to fix “Supplied nav_menu_item value missing property” after update to WordPress 5.0
- No “current-menu-ancestor” class added when browsing an archive page
- Create search form in menu as in Twenty Fourteen theme
- Change an li class name in a wordpress custom menu walker
- Separator for custom nav menu
- add_submenu_page function to show videos table
- Conditional secondary menus
- From a page, is it possible to find entry’s “menu_item_parent”?
- Nav and logo loading each time causing menu to move JointsWP – Foundation 6
- Creating a menu containing categories and authors
- Change submenu markup
- Using _s theme, menu changes do not affect header menu
- Show children (sub-navigation) of active menu item only
- Menu Arrow for Child Element
- Adding an external link to wordpress menu
- Add a counter beside menu item label
- Odd spacing in Navigation Bar [closed]
- wp_list_pages Hierarchical Help
- How to avoid the and which added when custon menu widget is used
- Add pages content to startpage through custom menu
- An alternative to WordPress’s built-in menu functionality
- Is there any way to change the CSS class applied to 2nd level sub menu ul’s?
- How to change how WordPress renders navigation menu on Block Themes
- Problem with links once in portfolio item
- url_to_postid method in walker_nav navigation menu causing exceptionally high TTFB
- Get Each Menu Nav Label of Menus in HTML tag
- insert an HTML element if there is a submenu only
- Add class to sub-menu from unrelated element
- How do I display menu in header without loosing styles?
- Adding additional html to the end of the root level in a custom nav walker
- Navigation bar is on live site but nothing under menu so can’t add in a page
- how do you create this customize menu using wp_nav_menu function?
- WordPress menu issue after update
- Displaying a part of a menu containing the page the user is currently viewing and only it’s immediate children
- Show thumbnail to category items in wp_nav_menu(), how?
- Replace Menu Item with Logged in username
- Menu support for touch devices
- ID of parent Menu
- Navigation list not correctly styled on pages with custom template (missing .current-menu-item)
- how to mage the submenu open on wordpress active page
- Is it possible to animate the Twenty Eleven menu? [closed]
- Off-Canvas Menu Toggle Issue After WordPress Core Update
- Remove WordPress Menu Classes and ID with Bootstrap Walker