There is indeed a filter, walker_nav_menu_start_el
will be able to handle it for you!
Take this code for example:
function wpse356896_filter_primary_nav_menu_dropdown( $item_output, $item, $depth, $args ) {
// Only for our primary menu location.
if ( empty( $args->theme_location ) || 'primary-menu' !== $args->theme_location ) {
return $item_output;
}
// Add the dropdown for items that have children.
if ( ! empty( $item->classes ) && in_array( 'menu-item-has-children', $item->classes ) ) {
return $item_output . '<span class="dropdown"><img src="https://wordpress.stackexchange.com/questions/356896/chevron.svg"></span>';
}
return $item_output;
}
add_filter( 'walker_nav_menu_start_el', 'wpse356896_filter_primary_nav_menu_dropdown', 10, 4 );
Related Posts:
- Theme: dropdown hover menu not showing up in IE/Edge
- WordPress API Menu/Submenu Order
- How to remove the Theme Customization Button from the dashboard and themes options page?
- What filters are applied to the_content function?
- Change admin bar to default:off
- How to modify an image block in Gutenberg WordPress 5?
- Add a dropdown to theme customizer
- Edit srcset and sizes attributes in Gutenberg image, cover and gallery – blocks
- wp_get_attachment_image_attributes not working for me
- Display a different theme for not logged-in users
- Run shortcode before filters
- Add class to before_widget for all widgets with a dropdown and a counter
- How to Auto Approve Comments on a Specific Page?
- Get password when user registers and save it sha1 into database
- Passing variable in hooks and filter
- WordPress nav_menu_css_class theme filter is not being called
- customizing the_password_form filter
- Custom Nav Walker Displaying Values in Sub Menu
- Custom Nav Walker to show siblings and children of current branch?
- WordPress Genesis Child Theme Filter divs
- Change file name from wp_generate_attachment_metadata
- Create self-populating menu and add extra divs to the menu layout
- Simple way to get two language WP site
- Find the Children of a Page then Echo it as a Bulleted List of Links (menu)
- Highlight “Show all” item in wp_list_categories
- When trying to override plugin’s function by theme, my filter executes two times, I want it to run only a single time
- Menu item added in wp_nav_menu_items filter is never highlighted
- wp_post->post_parent object returning 0
- Single-level menu option? Another way?
- Should I use add_filter for functions in function.php of the theme?
- Pass variable to hook. Its possible?
- WordPress taxonomy and archive custom class
- Filter categories used with Custom Structure Permalink
- Admin: sub menu doesnt display under apperance when activate my themes
- How to wrap all titles generated by Gutenberg “Heading” block with tag
- Replace single_template filter with what for default posts?
- How to develop a menu like wwe.com?
- Unique design inside a specific category’s url
- How to rotate every letter in a title
- How to disable thumbnail filter for a specific template part or image size?
- CSS class on last post in loop ( custom query )
- How to change footer credit text in Twenty Twenty One theme with a hook?
- Modify available templates (in dropdown)
- Templates dropdown not appearing using _s theme (underscores)
- Navbar- disable “onClick” drop-down
- tiny_mce_before_init: ‘exact’ => true has no effect
- How to conditionally add a wp_filter
- Filter didn’t work on content class (hybrid_post_attributes)
- How to set default values for edit_post_link() in my theme?
- Tiny MCE custom styles, and preview in the backend
- content filter (add_filter) for category description?
- Related Post Category Filter
- Pagination don’t work with active filters
- WordPress custom menu can’t show 3. level submenu
- How to register dynamic settings in WordPress Customizer?
- restrain filter on get_the_excerpt to queried item in stead of current post
- WordPress wp_get_current_user returning blank values until refresh
- Alternative solution for script_loader_tag?
- Show all menu levels except top level. How to exclude top level of a menu?
- Alt header logo and link for specific pages
- WordPress Twenty-Fourteen: How to Remove Home Page Header Image from Other Pages
- WordPress menu walker – Get parent item text inside end_lvl function
- Make a custom field in admin post.php read only
- Hook in parent theme Menu function
- How do I remove p tag *insertions*? Disabling `wpautop` removes manual tags
- How to add custom nav_menu_css_class to certain menu only?
- How to manipulate wordpress template tags’ output
- WordPress doesn’t recognize submenus as so I can’t style them properly
- what is do_action(); in wordpress? [duplicate]
- Menu order of parent menu from perspective of child menu
- Suppress the_content filter in a nested loop
- Main Menu Theme Different Output Print
- apply_filters to featured image
- Add rel to all images in a post
- How to create sub-menu in “Allure Real Estate Theme for Placester”?
- Add wrapper for a specific sub-menu
- Is there any filter or action hook to remove layout classes from appearing in my templates?
- Only show read more text when when wp:post-excerpt meets excerptLength
- WP “optimizing” PNGs into thumbnails 5X larger than originals – FIX
- optimized PNGs 5X larger than originals
- Menu items description? Custom Walker for wp_nav_menu()
- How to define and link full path to css located at a random folder on header.php
- Sizing screenshot.png without losing aspect ratio
- Software for WordPress Theme and Plugin Development? [closed]
- When to use is_home() vs is_front_page()?
- What is the preferred way to add custom javascript files to the site?
- Get the blog page URL set in Options
- How to create .pot files with POedit?
- How do I get the theme URL in PHP?
- Why when I submit a form in wordpress it loads a 404 page though URL is correct
- What is the constant WP_USE_THEMES for?
- Worthwhile to restrict direct access of theme files?
- How Do I Protect My Premium WordPress App Theme from Copying?
- How to detect mobile devices and present them a specific theme?
- Using wp_add_inline_style without a stylesheet
- How to add posts to custom menus?
- WordPress Theme Preview Image
- How To extend WP_Customize_Control
- What is the difference between front-page.php and home.php? [duplicate]
- How can I get page slug