Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Remove DIV and UL from WordPress wp_nav_menu(). This example replaces the registered menu 'header-menu' and replaces 'wp_nav_menu( array( 'theme_location' => 'header-menu' ) ) ;' with the function 'wp_nav_menu_head();' in your theme file. (For functions.php)
<?php
//REMOVE DIV and UL FROM WP_NAV_MENU
function wp_nav_menu_header(){
$options = array(
'echo' => false,
'container' => false,
'theme_location' => 'header-menu',
'fallback_cb'=> 'fall_back_menu'
);
$menu = wp_nav_menu($options);
echo preg_replace(array(
'#^<ul[^>]*>#',
'#</ul>$#'
), '', $menu);
}
//FALL BACK MENU
function fall_back_menu(){
wp_list_pages('title_li=');
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.