Ceezy
Ceezy

Reputation: 1

Adding a new navigation menu to WP theme

Need to add a secondary menu under my main menu. I see the menu through inspecting the page but it is BEHIND my main nav. I want it to be under it.

Not sure if its where i placed the code in the header file or my css is wrong. What should my css look like?

Added this to functions.php

function register_my_menu() {
  register_nav_menu('drug-menu',__( 'New Menu' ));
}
add_action( 'init', 'register_my_menu' );

Pasted this at the bottom of the header.php file.

<?wp_nav_menu( array( 'theme_location' => 'drug-menu', 'container_class' => 'new_menu_class' ) ); ?>

Here's more of the header.php where i think im running into the problem.

<body <?php body_class(); ?>>
    <?php wp_body_open(); ?>
    <div class="<?php echo esc_attr( $wrapper_div_classes ); ?>">
        <header class="header <?php echo esc_attr( $header_class ); ?>">
            <?php
            hestia_before_header_trigger();
            do_action( 'hestia_do_top_bar' );
            do_action( 'hestia_do_header' );
            hestia_after_header_trigger();
            ?>
        </header>
<?wp_nav_menu( array( 'theme_location' => 'drug-menu', 'container_class' => 'new_menu_class' ) ); ?>

Upvotes: 0

Views: 185

Answers (1)

Orman Faghihi Mohaddes
Orman Faghihi Mohaddes

Reputation: 225

You need to use register_nav_menus instead of register_nav_menu to have multiple menus.

Functions.php

function register_my_menus() {
    $args = array(
        "primary" => "Primary Navigation Menu",
        "footer" => "Footer Menu"
    )
    register_nav_menus($args);   
}
add_action("after_setup_theme", "register_my_menus");

Header.php

<?php wp_nav_menu(array("theme_location"=>"primary")); ?>

Other locations like Footer.php

<?php wp_nav_menu(array("theme_location"=>"footer")); ?>

Upvotes: 1

Related Questions