Archived topic
Add arrows to submenu
1 reply · Started by fredparson on April 14, 2022
This code does seem to work its supposed to add arrows to the sub menu. Anyone know whats wrong with the code?
function be_arrows_in_menus( $item_output, $item, $depth, $args ) {
if( in_array( 'menu-item-has-children', $item->classes ) ) {
$arrow = 0 == $depth ? '<i class="icon-angle-down"></i>' : '<i class="icon-angle-right"></i>';
$item_output = str_replace( '</a>', $arrow . '</a>', $item_output );
}
return $item_output;
}
add_filter( 'walker_nav_menu_start_el', 'be_arrows_in_menus', 10, 4 );
Hi there,
i am not sure why you need it as the GP Nav adds arrows for parent menu items.
But i tested the code and it does work, as i can see the <i class="icon-angle-down"></i> HTML being output.
That HTML looks like its reliant on the Font Awesome icon library which you would need to install or replace the HTML with a different icon/HTML symbol