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
- Is it possible to seperate wordpress menu by different div?
- How to add odd and even classes to all nav links through walker?
- Output sort number in wp menu list item?
- Add newsletter signup element to navigation bar
- How to separate sub-menu output and keep associated with parent
- How to Use Default Auto-Generated Menu?
- Has there been any improvements to wp’s menu handling?
- How to sort a sub-menu, generated with get_pages(), by the page order instead of alphabetically?
- wp-nav menu with custom walker , how to remove a tag if it has any submenu
- Programmatically add a Navigation menu and menu items
- Menu Details Output in Javascript [closed]
- Site-wide tabs at WordPress website?
- Custom location for menu
- Reveal hidden submenus on page load – Twenty Fifteen theme
- Creating custom Menu for custom theme
- Check in walker if current page is descendant
- How to add class and span to
- Always show wordpress submenu on responsive header menu
- wp_nav_menu not selecting teh correct menu
- Can’t add optional class to menu item when using Walker_Nav_Menu
- Active page link not getting class assigned
- Add dynamic content block to nav section generated by custom walker
- jQuery not working when used with wordpress menu
- Add a Submenu from Another Submenu in a Custom Theme
- Highlighting Main Navigation Menu With Two or More Class Matches
- How to display list of child pages with parent in wordpress?
- Next/previous a-like single navigation
- wp_dropdown_nav function to list menu items
- Customize Walker_nav_menu to show posts if item is category
- wp_nav_menu() reutrns HTTPS?
- Use menu structure for permalinks
- Menu not always using correct link
- How to output the menue structured for tabbed navigation?
- Replace Menu Item with Logged in username
- Where these arguments are defined?
- Show only second level menu items? [duplicate]
- Add item ONLY to the primairy navigation
- Adding two submenus to a menu
- How to create a menu super voice in WP?
- Update nav menu item position programmatically
- Navigational error
- Remove from wp_nav_menu() wordpress
- Add tooltips with image in WordPress Menu?
- Determine if a navigation item has children
- Image menu on responsive WordPress
- Walker for menus
- Building Menus with the latest posts included
- wp_nav_menu: indicate by id page grandparents
- Menu support for touch devices
- individual images as navigation design TwentyTen
- How to add drop down sub menu from database fields in the particular menu slug
- collapse twenty twelve submenu in mobile version
- WordPress Navigation
- Display all submenus
- WordPress Navigation default output
- How to call either page name as the nav link or navigation title?
- Second tier sidebar navigation
- Change sub-menu css class
- How to get wordpress navigation to work
- How do I get my nav menu to show sub pages?