Navigation
This is archived content. Visit our new forum.
  • Author
    Posts
  • #48571

    Ben H
    Participant

    Hi, I am using the X integrity theme of wordpress, and i am looking to add a new menu to my header, currently have top bar (social icons showing ) and a category nav.

    I need to add a new menu to get my cart/bag showing up?

    My theme says supports 2 menus. i want to add i new one?

    How do i do this?

    my dev site is here: http://dev.carandkitchen.co.uk/

    Theme Location Assigned Menu
    Primary Menu Categorues menu
    Footer Menu top level menu

    #48699

    Christian
    Moderator

    Hey Ben,

    To add an extra Header Menu location, please add the code below in your functions.php.

    function register_header_menu() {
      register_nav_menu('header-menu',__( 'Header Menu' ));
    }
    add_action( 'init', 'register_header_menu' );

    To output the menu in the template, use the code below.

    if ( has_nav_menu( 'header-menu' ) ) :
    	wp_nav_menu( array(
    	  'theme_location' => 'header-menu',
    	  'container'      => false,
    	  'menu_class'     => 'x-nav sf-menu'
    	) );
    endif;

    Hope that helps. 🙂

    #49463

    Ben H
    Participant

    That work, added it, just need to style now! – with x theme is there no default bag/cart links?

    also if i wanted to add another menu, can i do the same thing again, but change the naming.?

    #49466

    Ben H
    Participant

    Wait a minute those links even show in the backend, inside the dashboard…

    how do i stop this? when you said to output
    output the menu in the template, use the code below.

    Were was this meant to be placed? – not within the functions.php?

    #49785

    Christian
    Moderator

    Hey Ben,

    X doesn’t come with cart links but you can use the Woocommerce Cart widget in your sidebar.

    And yes, you can use the same code. Just replace header-menu with a different name.

    The code

    if ( has_nav_menu( 'header-menu' ) ) :
    	wp_nav_menu( array(
    	  'theme_location' => 'header-menu',
    	  'container'      => false,
    	  'menu_class'     => 'x-nav sf-menu'
    	) );
    endif;

    must be place on a template file like wp-header.php located in framework/views/(YOUR STACK) not in functions.php.

    Hope that helps. 🙂

    #49990

    Ben H
    Participant

    Added this to the wp_header.php

    <?php if ( has_nav_menu( ‘header-menu’ ) ) :
    wp_nav_menu( array(
    ‘theme_location’ => ‘header-menu’,
    ‘container’ => false,
    ‘menu_class’ => ‘x-nav sf-menu’
    ) );
    endif; ?>

    it didnt work?

    my full code here..

    <?php

    // =============================================================================
    // VIEWS/INTEGRITY/WP-HEADER.PHP
    // —————————————————————————–
    // Header output for Integrity.
    // =============================================================================

    ?>

    <?php x_get_view( ‘global’, ‘_header’ ); ?>

    <!–
    BEGIN #top.site
    –>

    <div id=”top” class=”site”>

    <?php x_get_view( ‘global’, ‘_slider-revolution-above’ ); ?>

    <header class=”<?php x_masthead_class(); ?>” role=”banner”>
    <?php x_get_view( ‘global’, ‘_topbar’ ); ?>
    <?php x_get_view( ‘global’, ‘_navbar’ ); ?>
    <?php x_get_view( ‘integrity’, ‘_breadcrumbs’ ); ?>

    <?php if ( has_nav_menu( ‘header-menu’ ) ) :
    wp_nav_menu( array(
    ‘theme_location’ => ‘header-menu’,
    ‘container’ => false,
    ‘menu_class’ => ‘x-nav sf-menu’
    ) );
    endif; ?>
    swimwear365
    </header>

    <?php x_get_view( ‘global’, ‘_slider-revolution-below’ ); ?>
    <?php x_get_view( ‘integrity’, ‘_landmark-header’ ); ?>

    #50202

    Rad
    Moderator

    Hi Ben,

    Try it without has_nav_menu() condition.

    <?php wp_nav_menu( array(
    	  'theme_location' => 'header-menu',
    	  'container'      => false,
    	  'menu_class'     => 'x-nav sf-menu'
    	) );
    ?>

    And be sure that your file name is wp-header.php and not wp_header.php

    Let us know.