The wp_nav_menu()
function has a ton ( or bunch ) of parameters which makes customization fairly easy. I believe the one you’re specifically looking for is after
which will add a passed string into the list after the link. An example would look like this:
wp_nav_menu( array(
'menu' => 'Main Menu',
'container' => 'nav',
'theme_location'=> 'primary',
'after' => '<span></span>',
) );
And would output something like this:
<nav>
<ul>
<li><a href="#">Text</a><span></span></li>
</ul>
</nav>
Alternatively, you could use the wp_nav_menu_args
hook in functions.php
to modify the arguments for the primary menu:
function modify_main_menu( $args ) {
if( isset( $args['theme_location'] ) && 'primary' === $args['theme_location'] ) {
$args['after'] = '<span></span>';
}
return $args;
}
add_filter( 'wp_nav_menu_args', 'modify_main_menu' );