WordPress.org

Support

Support » How-To and Troubleshooting » Menu_id and menu_class will not work properly with wp_nav_menu();

Menu_id and menu_class will not work properly with wp_nav_menu();

  • According to wordpress.org – Function Reference/wp_nav_menu the menu_id and menu_class will give the ul an id and/or a class. For some reason it doesn’t.

    header.php:

    <?php wp_nav_menu( array( 'theme_location' => 'primary-menu', 'menu_id' => 'nav', 'menu_class' => 'clearfix', 'show_home' => '1' ) ); ?>

    functions.php:

    <?php
    add_action( 'init', 'register_my_menu' );
    function register_my_menu() {
    register_nav_menu( 'primary-menu', __( 'Primary Menu' ) );}
    ?>

    The menu_class creates a div with the given classname and wraps it around the ul while the menu_id doesn’t seem to have an effect at all. I want to give the ul an id and a class. In advance, thanks.

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Menu_id and menu_class will not work properly with wp_nav_menu();’ is closed to new replies.
Skip to toolbar