I’m trying to format the list produced by wp_nav_menu() so that within each <li> is a <span> that wraps the text. At first I thought I could accomplish this using the the items_wrap argument, but that changes only the enclosing <ul>, correct? This seems like it should be simple enough to accomplish. Thanks!

2 Answers
2

Yes, items_wrap is used to to modify or replace the default <ul> wrapper. To wrap the individual links inside of that element, simply use link_before and link_after, like so:

wp_nav_menu( array( 
    'theme_location' => 'some-location',
    'link_before' => '<span>',
    'link_after' => '</span>',
) );

Tags:

Leave a Reply

Your email address will not be published. Required fields are marked *