• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

WP SITES

2786

Original Genesis & WooCommerce Tutorials & 6000+ Guaranteed Code

Snippets

  • Try Premium
  • Log in

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:

Register for full access

Related Code

  • Different Menu On WooCommerce Pages

Nav Menu WooCommerce

Reader Interactions

Comments

  1. WWHaT says

    February 11, 2017 at 2:40 am

    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?

    Log in to Reply
    • Brad Dalton says

      February 11, 2017 at 3:26 am

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

      remove_action( 'genesis_after_header', 'genesis_do_nav' );
      
      remove_action( 'genesis_after_header', 'genesis_do_subnav' );

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

      Log in to Reply
      • WWHaT says

        February 12, 2017 at 7:52 am

        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.

        Log in to Reply
        • Brad Dalton says

          February 12, 2017 at 8:00 am

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

          Log in to Reply
          • WWHaT says

            February 12, 2017 at 8:49 am

            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.

          • Brad Dalton says

            February 12, 2017 at 9:00 am

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

          • WWHaT says

            February 12, 2017 at 9:09 am

            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 says

    September 20, 2016 at 8:57 pm

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

    Log in to Reply
    • jmelee1221 says

      September 20, 2016 at 9:17 pm

      Actually it isn’t working. 🙁

      Log in to Reply
      • Brad Dalton says

        September 20, 2016 at 11:35 pm

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

        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( '<a href="http://agirlsgottaspa.com/store/" title="%s" rel="nofollow">%s</a>', esc_attr( get_bloginfo('name') ), get_bloginfo('name') );
        	$title = sprintf('<%s id="title">%s</%s>', $wrap, $inside, $wrap);
        	return $title;
        	} else {
        	return $title;
        	}
        }
        Log in to Reply
  3. jmelee1221 says

    September 20, 2016 at 8:27 pm

    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..

    Log in to Reply
    • Brad Dalton says

      September 20, 2016 at 8:36 pm

      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?

      Log in to Reply
      • jmelee1221 says

        September 20, 2016 at 8:44 pm

        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?

        Log in to Reply
        • Brad Dalton says

          September 20, 2016 at 9:25 pm

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

          Log in to Reply

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Code written by Brad Dalton specialist for Genesis, WooCommerce & WordPress theme customization. Read More…

Advertise · WPEngine · Genesis · Log in

  • Access Problems
  • Account Details
  • Consulting
  • Tags
 

Loading Comments...
 

You must be logged in to post a comment.