Remove wrapping div and ul from output of wp_nav_menu

Removing 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'. This will remove the ul:  ‘items_wrap’ => ‘%3$s’

Otherwise this function will remove the div for you:


// Remove the DIV container from around WordPress menus
add_filter( 'wp_nav_menu_args', 'my_wp_nav_menu_args' );
function my_wp_nav_menu_args( $args = '' ) {
 $args['container'] = false;
 return $args;
} // function

Revisions

Tags: , ,

No comments yet.

Leave a Reply