Skip to content

Instantly share code, notes, and snippets.

@antcms
Created June 16, 2016 02:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antcms/a49257433ff9ebee382c55a469046c5e to your computer and use it in GitHub Desktop.
Save antcms/a49257433ff9ebee382c55a469046c5e to your computer and use it in GitHub Desktop.
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