Wordpress - Remove wrapping div and ul from output of wp_nav_menu

wp_nav_menu() accepts an undocumented parameter

'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>'

This is executed by: $nav_menu .= sprintf( $args->items_wrap, esc_attr( $wrap_id ), esc_attr( $wrap_class ), $items );

you can play around with the sprintf arguments

ex: 'items_wrap' => '%3$s' would remove the wrapping <ul> tag


The wrapping div is easy. When you use wp_nav_menu(), add this argument: 'container' => false

For the <ul> element, there's an argument called 'items_wrap'. See woodchucky's answer for more info on that one (and upvote it!).


For outputting only li's add this to wp_nav_menu array:

'container'      => '',
'items_wrap'    => '%3$s',