Wordpress - How do I remove UL on wp_nav_menu?
Actually, WordPress supports this by default:
wp_nav_menu(array(
'items_wrap' => '%3$s'
));
The default for items_wrap
is <ul id=\"%1$s\" class=\"%2$s\">%3$s</ul>
.
The function wp_nav_menu takes an argument of fallback_cb which is the name of the function to run if the menu doesn't exist. so change you code to something like this:
function wp_nav_menu_no_ul()
{
$options = array(
'echo' => false,
'container' => false,
'theme_location' => 'primary',
'fallback_cb'=> 'fall_back_menu'
);
$menu = wp_nav_menu($options);
echo preg_replace(array(
'#^<ul[^>]*>#',
'#</ul>$#'
), '', $menu);
}
function fall_back_menu(){
return;
}
you can even remove the container from the menu and do other stuff with some more arguments sent to the wp_nav_menu function
Hope this helps.
The below code should simple do it.
<?php
$my_menu = array(
'menu' => 'main-menu',
'container' => '',
'items_wrap' => '%3$s'
);
wp_nav_menu( $my_menu );
?>
Reference this link for the wp_nav_menu function http://codex.wordpress.org/Function_Reference/wp_nav_menu