Remove UL on wp_nav_menu

How to remove the UL and Div containers on the wp_nav_menu() function.

function wp_nav_menu_no_ul() {
    $options = array(
	 'menu' => 5, // update with menu ID
        'echo' => false,
        'container' => false,
        'theme_location' => 'primary',
        'fallback_cb'=> 'default_page_menu'

    $menu = wp_nav_menu($options);
    echo preg_replace(array(
    ), '', $menu);

function default_page_menu() {

Place in template to show menu (wrap with container of choice:

<?php  wp_nav_menu_no_ul(); ?>


Leave a Reply

katherine as a flat graphic icon

About Me

I’m an African / Ojibwe First Nations Web Developer living in Winnipeg, Manitoba.

Visit the Tips and Blog to see what I’m working on.