• I’m writing my own theme and getting strange html-code while trying to create the navigation menu. When I’m trying to generate the menu with this code:
    wp_nav_menu( array( 'sort_column' => 'menu_order', 'container_id' => 'menu' ) );
    I’m getting this code:

    <div class="menu"><ul><li class=""><a href="http://localhost/wp2/sample-page">Sample Page</a></li><li class=""><a href

    (the rest is skipped). The problem here is that wp_nav_menu() applies “container_id” parameter to the container class not the container id (as it should according to the reference http://codex.wordpress.org/Function_Reference/wp_nav_menu and PHPDoc inside wp-includes/nav-menu-template.php file).
    There is one more thing. When I’m trying to generate the menu with this code:
    wp_nav_menu( array( 'sort_column' => 'menu_order', 'menu_class' => 'slider-space', 'container_id' => 'menu' ) );

    I’m getting this:
    <div class="slider-space"><ul><li class=""><a href="http://localhost/wp2/sample-page">Sample Page</a></li><li class=""><a href=

    which means that the “menu_class” parameter is being applied to the container not the ul tag containing menu items (as it should according to the reference).

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘wp_nav_menu() generates unexpected html-code’ is closed to new replies.