/** * Attach icon class to the menu title * * @param $sorted_menu_items * @param $args * @return mixed */ function wti_add_arrow_to_parent_menu_item($sorted_menu_items, $args) { foreach ($sorted_menu_items as $menu_item) { if (array_search('menu-item-has-children', $menu_item->classes) != FALSE) { $menu_item->title = $menu_item->title . '<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg"> <path d="M19.9201 9.44995L13.4001 15.97C12.6301 16.74 11.3701 16.74 10.6001 15.97L4.08008 9.44995" stroke="#fff" stroke-width="1.5" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/> </svg>'; } } return $sorted_menu_items; } // Dropdown arrows to parent menu items add_filter('wp_nav_menu_objects', 'wti_add_arrow_to_parent_menu_item', 10, 2);
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter