Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress custom menu displayng all pages

I have created two custom menus on my wordpress site.

Both menus setup in Appearance -> Menus. However both menus display the same set of pages which was all at the time of creation and cannot be changed despite creating two separate menus and assigning this to the locations set.

Declared in function.php

function register_my_menus() {
  register_nav_menus(
    array(
      'main-menu' => __( 'Main Menu' ),
      'extra-menu' => __( 'Store Menu' )
     )
   );
 }
 add_action( 'init', 'register_my_menus' );

Set theme location.

<?php wp_nav_menu( array( 'theme_location' => 'Main Menu', 'container_class' 'menu_class' ) ); ?>
<?php wp_nav_menu( array( 'theme_location' => 'Store Menu', 'container_class' => 'storeMenu_class' ) ); ?>
like image 730
jacket52 Avatar asked Oct 17 '25 06:10

jacket52


1 Answers

Try Below Code. You have to use main-menu & extra-menu as "theme_location"

<?php wp_nav_menu( array( 'theme_location' => 'main-menu', 'container_class'=> 'menu_class' ) ); ?>
<?php wp_nav_menu( array( 'theme_location' => 'extra-menu', 'container_class' => 'storeMenu_class' ) ); ?>
like image 130
kinjal jethva Avatar answered Oct 18 '25 21:10

kinjal jethva



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!