I've created a menu using wp_nav_menu in my theme using the most simple setup as possible:
wp_nav_menu( array( 'theme_location' => 'my_theme_top_menu') );
And in my functions.php:
register_nav_menus(
array('my_theme_top_menu' => 'Top Menu' )
);
However, I'm running into strange behaviour when the user creates a menu in wp-admin and assigns it to this menu. When you first select the theme, it defaults to the default menu built from pages, the markup looks like this:
<div class="menu">
<ul>
<li class="page_item page-item-51">
<a href="http://www.mdunham.co.uk/bligs/">About Us</a>
But, if a user selects one of their pre-defined menus the markup that builds the menu completely changes:
<div class="menu-main-menu-container">
<ul id="menu-main-menu" class="menu">
<li id="menu-item-102" class="menu-item menu-item-type-post_type menu-item-object-page current-menu-item page_item page-item-29 current_page_item menu-item-102">
<a href="http://www.site.co.uk/">Home</a></li>
Why is this happening? It's like when uses a defined menu WP menu it WP defaults(or settings I've defined), yet when there is no defined menu and it falls back it uses a different, bastardized set of options which I haven't actually set anywhere myself.
wp_nav_menu
with the default list of pages.wp_list_pages()
function and change the markup it generates.