The $args parameter are the arguments of the entire menu not of the single menu item, you can see it here in the file itself that uses and executes the filter:
@param stdClass $args An object of wp_nav_menu() arguments.
so when your IF is true (the item is a parent item), you are modifying the entire Menu arguments:
$args->link_after = "</span><span class="caret"><i class="dropdown-indicator"></i></span>";
so all menu items after the parent item would have the dropdown indicator.
If you want to add the dropdown indicator you will have to do the classic custom walker way, where you create your own class:
class Custom_Nav_Walker extends Walker_Nav_Menu{}
and override the start_el function, you will find plenty of info about it.
Related Posts:
- automatically adding submenu items
- Logout hyperlink within a sub-menu
- Custom Nav Walker sub-menu
- retrieves menu and converts it to a readable array
- Add Login/Logout Menu Item to Primary Nav “My Account” Submenu [Woocommerce] [closed]
- How to hightlight all ancestor menu items of a child page NOT displayed in menu
- Unable to add extra elements to the main navi (wp_nav_menu_items)
- Conditional custom menu?
- Modify sub_menu function to show pages below a specifically set page
- How do I get my nav menu to show sub pages?
- How to add a data attribute to a WordPress menu item
- Get the ID of the page a menu item links to?
- Add container to nav_menu sub menu
- Get menu object from theme_location
- Remove a menu item created by a plugin
- Remove Container Element From wp_nav_menu() Markup
- Using wp_get_nav_menu_items() to list children of children pages
- How to target specific wp_nav_menu in function?
- Breadcrumbs showing Parent and Child Pages
- Custom menus displaying all pages instead of set pages
- Return only top-level navigation items from a menu using wp_get_nav_menu_items
- How to activate “Description” metabox for menu item programmatically?
- Dynamically add sub-categories to any category in the menu
- Breadcrumb how i can display page title with parent > child title with permalink ? any Idea
- Two different menus for two different locations?
- Unregister Nav Menu with fallback?
- How to programmatically set a menu to be the Primary Menu?
- Editing or filtering the output of the Genesis navigation
- Make Categories a Dropdown Menu in Media Library
- Make menu structure match page heirarchy on page parent change
- Is there a way to add a class to non current menu item?
- Menu fallback “menu_class” rendering a “div” instead of a “ul”
- CSS for menu item added via functions.php
- How To Remove Duplicate Menu Locations
- Where do I add html code to the menu div?
- Replace menu links with # and add name to its li
- How do I create page navigation linking to each H2 within the page? [closed]
- Function issue with Walker_Nav_Menu [duplicate]
- Why does the ‘wp_nav_menu’ function work only until a menu is created?
- Custom Static Links For Specific Menu Right Before/Next The wp_nav_menu Function now working
- Make parent page only link to first subpage
- How to add nav menu items to a specific position within a menu
- wp_nav_menu, walker class, categories as classes of li
- Hard-coding custom menu elements for menu manager
- Dynamic dropdown from database table
- Where to start learning more about wordpress templates [closed]
- How to fetch the name of the active menu?
- Replace a menu with widget or a custom template file programmatically
- WordPress Quick Question . How to Get Parent Link in Submenu in My Code
- Categories as main menu items and subcategories as nested lists
- getting the current sub item out of total sub items in a given dropdown (custom walker)
- Removing specific menu items?
- How do I hook into the container of wp_nav_menu?
- New custom menu created. how to apply it?
- Dropline menus — seperators between children only?
- Filter nav menu items HTML tags and wrap inner text with span
- Functions php shortcode for displaying main menu with no child items
- Nav menus all outputting the same links
- Secondary Menu and Logged In Users
- Change menu based on page template via functions.php
- Show some menu sub items as dropdown under a menu item
- How to add custom li item to wordpress menu
- Default Nav Highlight
- How to use wp_nav_menu to create custom dropdown menu?
- Different methods of adding menu support to custom theme
- Adding a section in line at the end of the main navigation menu in php
- Multiple navigation menu in same location
- wp_nav_menu work in functions.php but not in the theme
- How to register a menu based on a ACF condition
- current_page_item is missing inside wp_nav_menu
- search form leads to 404
- Remove submenu item from list
- How Can I add a menu to the theme from withen the function.php file
- define css class in functions.php
- Add Login and logout buttons to top menu bar
- Custom Menu in Admin doesn’t change menu in browser
- Dropdown primary navigation menu not working
- Is there any way to change the CSS class applied to 2nd level sub menu ul’s?
- How would I make a function to dynamically determine if user is logged to change navigation menu text?
- wp_nav_menu displaying all pages
- Warning at top of website & top menu gone
- Change WooCommerce Payment Options From Radio Buttons to Dropdown Menu
- How to display an image before title text in menu items
- Bizarre Child Menu Issue on WP Site
- Header menu aligned right on all pages except for single-post page [closed]
- Hide ‘add to cart’ when certain value in dropdown is selected
- Theme: dropdown hover menu not showing up in IE/Edge
- How to automatically add counted number to navigation menu items?
- Combine multiple menus using the filter wp_nav_menu_items
- Menu and category highlighting for a single post
- WordPress Toggle Menu has stopped working
- Drop down list code for sidebar
- How to add widget in main menu
- Language Switch Function
- Insert menu into theme location depending on user logged in/out status
- Reveal hidden submenus on page load – Twenty Fifteen theme
- How I can add div to menu?
- Adding custom field in menu options [duplicate]
- wp_nav_walker that interacts with widgets to setup mega menu
- Adding a filter with custom function to the menu / navigation