How do I fix my header menu changes when creating a new menu?


Jonathan Orie

I want to create a submenu in a page that I can access from my header menu. I created the submenu, added a line to "register_nav_menus". I want the submenu's page to have the code for theme_location corresponding to the code added to "register_nav_menus".

Now my header menu is the submenu I just created. (I updated the location in the menu admin page).

I really don't know what I can do to fix this. I am very new to WP.

Here is the code:

FUNCTIONS.PHP
// Theme Setup
function mairie_setup() {
    // Navigation resgister
    register_nav_menus(
        array(
            'header' => __('Menu principal'),
            'subnav' => __('Sous menu')
        )
    );
}
add_action('after_setup_theme', 'mairie_setup');

HEADER.PHP
...
<nav class="navbar">
    <?php
        $args = array(
        'theme_location' => 'header'
    );
    wp_nav_menu() ?>
</nav>
...
THEME FOR SUBNAV
...
<nav class="sub_navbar">
    <?php
    $args = array(
        'theme_location' => 'subnav'
    );
    wp_nav_menu() ?>
</nav>
...


I'd like my header menu to stay the header menu and not change if I create a new menu.
Ripon
<nav class="navbar">
  <?php
    $args = array(
      'theme_location' => 'header'
    );
    wp_nav_menu($args);
  ?>
</nav>
<nav class="sub_navbar">
  <?php
    $argss = array(
      'theme_location' => 'subnav'
    );
    wp_nav_menu($argss);
  ?>
</nav>

Please try this one. and read more about https://developer.wordpress.org/reference/functions/wp_nav_menu/

Related


How do I close my slideshow menu when I click outside?

User 11080824 I have a hamburger menu that slides in from a website. Everytime I select a cell it closes the menu. I want to add a TapRecognizer so that when you tap outside it also closes it. var isPresenting = true let dimmingView = UIView() func transition

How do I fix my header menu changes when creating a new menu?

Jonathan Orie I want to create a submenu in a page that I can access from my header menu. I created the submenu, added a line to "register_nav_menus". I want the submenu's page to have the code for theme_location corresponding to the code added to "register_na

How do I close my slideshow menu when I click outside?

User 11080824 I have a hamburger menu that slides in from a website. Everytime I select a cell it closes the menu. I want to add a TapRecognizer so that when you tap outside it also closes it. var isPresenting = true let dimmingView = UIView() func transition

How do I convert my slideshow menu to a Foursquare menu?

Sajeethharan Now, I have a sliding menu like below, I want to style it as a Foursquare sliding menu, this is my layout <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id=

Why are my Firefox menu arrows enlarged? How can I fix this?

BTownTKD I recently formatted my laptop (Windows 8.1 RTM) and reinstalled a lot of software from scratch. After setting up Firefox, I noticed that the "fly out" arrow in the Firefox menu was absurdly enlarged. This is the case with all menus in Firefox, includ

How to fix header and main menu overlay content?

fuel online I know there are many answers here. But I'm asking this question again because I'm not a developer. I made a website out of simple medicines and drops. I don't understand CSS. I'm in trouble. The content is overwritten due to the header and main me

How can I move my header logo above the menu items?

Remo I'm trying to optimize my shopify store for mobile devices. But I'm running into a problem that I can't solve. My mobile version now looks like this: I want to make the logo bigger, but I also need to show other icons. I'm wondering if it's possible to mo

How do I convert my slideshow menu to a Foursquare menu?

Sajeethharan Now, I have a sliding menu like below, I want to style it as a Foursquare sliding menu, this is my layout <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <Button android:id=

Why are my Firefox menu arrows enlarged? How can I fix this?

BTownTKD I recently formatted my laptop (Windows 8.1 RTM) and reinstalled a lot of software from scratch. After setting up Firefox, I noticed that the "fly out" arrow in the Firefox menu was absurdly enlarged. This is the case with all menus in Firefox, includ