Add Custom Menu To Specific WooCommerce Pages Only

If you’re selling from your WordPress site using Woocommerce, you might want to add an additional nav menu which only displays on WooCommerce related pages.

woocommerce-menu

This code, enables you to:

  1. Control which WooCommerce pages the menu displays on.
  2. Determine which location on the page you want the menu positioned using genesis hooks.
  3. Exclude or include specific pages.

Simply add the following PHP code to the end of your child themes functions file using a code editor:

Related Code


Comments

14 responses to “Add Custom Menu To Specific WooCommerce Pages Only”

  1. How could I Remove(hide) Primary and secondary Navigation Menu From menu Page? I just want to show woo commerce menu at the top menu . Any chance you can help?

    1. Brad Dalton Avatar
      Brad Dalton

      The following code assumes your menus are hooked using the genesis_after_header hook and removes both menus from the front end.

      [code]
      remove_action( ‘genesis_after_header’, ‘genesis_do_nav’ );

      remove_action( ‘genesis_after_header’, ‘genesis_do_subnav’ );
      [/code]

      Or are you referring to removing the menus from Appearance > Menus on the admin page?

      1. Hi,Brad I’m sorry that the way I narrate is unclear. My problem is Remove(hide) Primary and secondary Navigation Menu , When I am in the WooCommerce Pages , and just show woo commerce menu. Not in my all web sites.

        1. Brad Dalton Avatar
          Brad Dalton

          You can use the code below to do that with conditional tags for woocommerce

          1. sorry, I have another problem is that I want to add second Custom Menu To Specific WooCommerce Pages Only.
            It’s mean that I will have two Custom Menu to WooCommerce Pages Only.

          2. Brad Dalton Avatar
            Brad Dalton

            Sure, i have code for this. Did you search?

          3. Yes, I did. I try to do from this ” Adding Additional Nav Menu’s in Genesis” , but it’s not show on WooCommerce Pages Only.
            sorry, I’m a little fool.

  2. jmelee1221 Avatar

    Actually I figured it out. I am so dumb. I didn’t see the WooCommerce Menu drop down in the menus. Sorry about that!

    1. jmelee1221 Avatar

      Actually it isn’t working. 🙁

      1. Brad Dalton Avatar
        Brad Dalton

        Here’s the code you can add to your functions file

        [code]
        add_action( ‘genesis_after_header’, ‘woocommerce_shop_page_menu’, 12 );
        function woocommerce_shop_page_menu() {

        if ( ! class_exists( ‘WooCommerce’ ) )
        return;

        if ( is_woocommerce() || is_checkout() || is_account_page() || is_cart() || is_product() || is_shop() ) {
        genesis_nav_menu( array(
        ‘theme_location’ => ‘woocommerce-menu’,
        ‘container’ => false,
        ‘depth’ => 1,
        ‘fallback_cb’ => false,
        ‘menu_class’ => ‘genesis-nav-menu wrap’,
        ) );
        }
        }

        add_filter( ‘genesis_seo_title’, ‘sp_seo_title’, 10, 3 );
        function sp_seo_title( $title, $inside, $wrap ) {

        if ( ! class_exists( ‘WooCommerce’ ) )
        return;

        if ( is_woocommerce() || is_checkout() || is_account_page() || is_cart() || is_product() || is_shop() ) {

        $inside = sprintf( ‘%s‘, esc_attr( get_bloginfo(‘name’) ), get_bloginfo(‘name’) );
        $title = sprintf(‘<%s id="title">%s‘, $wrap, $inside, $wrap);
        return $title;
        } else {
        return $title;
        }
        }
        [/code]

  3. jmelee1221 Avatar

    I used the code above and it’s not working. I changed the info to match what I wanted, but on the product pages, and shop page its not work for my header_left menu. Any chance you can help?

    Thanks in advance..

    1. Brad Dalton Avatar
      Brad Dalton

      Please email me a copy of your theme which includes the code and i’ll fix it for you.

      What theme are you using and what do you mean by header_left menu?

      1. jmelee1221 Avatar

        I am using a child theme from Hello You Designs called Hello Glam.

        Currently I am on a test site, so if it makes it easier I can give you access to login and check it?

        1. Brad Dalton Avatar
          Brad Dalton

          OK. Please email me FTP hostname, username and password. brad@wpsites.net

Leave a Reply

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.