• Resolved db9429

    (@db9429)


    Hi!

    I’ve just discovered Quark, and thought it looks awesome – and it is, but I’m just having some issues with creating a secondary nav.

    Basically, I have created a child theme, and all seems to be fine there.

    I have a fresh functions.php in my child theme with:

    register_nav_menus( array(
    	'tagtiv8-product-menu' => esc_html__( 'Tagtiv8 Products Menu', 'tagtiv8-products-menu' )
    ) );

    I have added the menu to header.php using:

    <div class="banner row">
    		      <nav id="product-navigation" class="secondary-navigation" role="navigation">
    		         <?php wp_nav_menu( array( 'theme_location' => 'tagtiv8-products-menu', 'menu_class' => 'tagtiv8-products-menu' ) ); ?>
    		      </nav> <!-- /#product-navigation.secondary-navigation -->
    		   </div> <!-- /.banner.row -->

    I have then created the menu in WP, and selected the location.

    I have then selected 4 items to be added to the menu, and they are the only 4 items in there.

    One of the issues is, ‘Home’ is being displayed in the menu, and I can’t see why it’s being added.

    The other issue is, when I add a CSS class to a menu item on the secondary menu, it doesn’t actually add the class when I check it via inspector on the front end.

    If I add a class to the primary menu, it works fine.

    The site is currently at: https://j.mp/19IbKec

    So far, I’ve tried completely deleting WordPress, reinstalling and recreating the child theme. I only have 20-30 lines of CSS, a custom header and the lines shown above in functions.php.

    Any assistance would be greatly appreciated.

    Many Thanks.

Viewing 1 replies (of 1 total)
  • Theme Author Anthony Hortin

    (@ahortin)

    Try changing register_nav_menus to register_nav_menu (ie. drop the ‘s’).

    Also, when using esc_html__ the second parameter is actually the text domain. This is typically the theme name in lowercase characters.

    The reason the home menu option is showing is because wp_nav_menu can’t find the Theme Location and the actual function that is displaying your menu is wp_page_menu(), which automatically adds the Home option.

    If you read the first couple of paragraphs for wp_nav_menu() in the Codex, you’ll see that the output of this function will fallback to wp_page_menu if a valid theme_location isn’t supplied.

    In your call to wp_nav_menu, theme_location should actually be tagtiv8-product-menu.

    So basically, the proper code should be something like…

    In functions.php

    register_nav_menu( array(
    	'tagtiv8-product-menu' => esc_html__( 'Tagtiv8 Products Menu', 'tagtiv8theme' )
    ) );

    Wherever you want your menu displayed

    <div class="banner row">
       <nav id="product-navigation" class="secondary-navigation" role="navigation">
          <?php wp_nav_menu( array( 'theme_location' => 'tagtiv8-product-menu', 'menu_class' => 'tagtiv8-nav-menu' ) ); ?>
       </nav> <!-- /#product-navigation.secondary-navigation -->
    </div> <!-- /.banner.row -->

Viewing 1 replies (of 1 total)
  • The topic ‘Secondary Navigation Issue’ is closed to new replies.