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:
- 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
- Programmatically add a Navigation menu and menu items
- Call custom field into menu item
- Exclude Private, Draft pages from Primary Nav when using custom menu
- wp_nav_menu always falls back to a menu
- wp_get_nav_menu_items how to exclude sub level menu items?
- Add class to top level menu item if it has multiple child levels
- Add custom attributes to menu items without plugin
- Simple Navigation Walker – Wrapper-class around first sub-menu
- How to drag multiple menu items at once in WordPress?
- Customizing the a tag with Semantic UI
- Not able to get current menu ID
- how to only add a top-level admin menu without it creating a sub-level-menu
- Why is ‘nav_menu_item_args’ filter’s $item argument empty?
- WordPress wp_nav_menu with a nav tag
- `start_el` depth argument in custom nav walker always evaluates to zero
- Programmatically set current-menu-item using wp_nav_menu
- Adding Custom “Current Menu Item” class to navigation?
- How to fix “Supplied nav_menu_item value missing property” after update to WordPress 5.0
- Conditional secondary menus
- current-menu-item class is not added
- Nav and logo loading each time causing menu to move JointsWP – Foundation 6
- Creating a menu containing categories and authors
- Change submenu markup
- wp_page_menu not working right?
- How to get rid of the home link in nav menu?
- Is it possible to add a dynamic link in the main navigation in a child theme
- display menu as table layout
- Insert a div class inside wordpress menu
- How to make wordpress nav menu use post custom meta data
- retrieves menu and converts it to a readable array
- Switch an entire nav menu if user is logged in
- Drop Down menu expanded by default (on front page) [closed]
- 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
- 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
- Menu walker: how to tell if a sub menu contains submenus?
- 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
- Walker or wp_get_nav_menu_items VS jQuery
- I can’t correctly display menu
- Show thumbnail to category items in wp_nav_menu(), how?
- Replace Menu Item with Logged in username
- Where these arguments are defined?
- ID of parent Menu
- Show All Children of WordPress Menu
- Navigation list not correctly styled on pages with custom template (missing .current-menu-item)
- How to make an anchored page in a navigation menu tab
- how to mage the submenu open on wordpress active page
- nav tag wrapping around dropdown
- Is it possible to animate the Twenty Eleven menu? [closed]
- Add featured posts to nav menu