Am using the custom menu widget to add a menu in the footer and i want to add a in the menu how can i do this ?
like so…
<li><a href=""><span>menu1</span></a></li>
if done it for the main nav using the link before below but as this is a widget am not sure where to add this
'link_before' => '<span>',
'link_after' => '</span>'
any one know ?
1 Answer
Filter 'walker_nav_menu_start_el'
and replace the link text.
Prototype, not tested:
add_filter( 'walker_nav_menu_start_el', 'wpse_56028_title' );
function wpse_56028_title( $item )
{
return preg_replace( '~(<a[^>]*>)([^<]*)</a>~', '$1<span>$2</span></a>', $item);
}