Primary Navigation Menu for WooCommerce Shop

I am trying to match the Integrity Demo navigation menu for WooCommerce Shop page. On the Integrity Demo, there is a primary menu for the site, then when you click on Shop it takes you to the shop page but the menu is different. How do I accomplish this on my own site? Is there step by step instructions somewhere or a video tutorial on how to do this?

2 Likes

Hi there,

You can use the following code in your child themes functions.php

add_filter( 'wp_nav_menu_args', 'custom_blog_menu' );

function custom_blog_menu( $args ) {
  if ( x_is_product() || x_is_product_index() ) {
    $args['theme_location'] = 'primary';
    $args['menu'] = 'Custom Menu';
  }
  return $args;
}

Just replace Custom Menu, with the actual menu name.

Thanks!

1 Like

Awesome! thank you so much it worked perfectly. Exactly what I wanted. Thanks for the help.

Ok, sorry but I also need this menu to stay when I click on the other menu items, like checkout, my account, and cart. How do I do this?

Hi There,

Please update the provided code to this:

add_filter( 'wp_nav_menu_args', 'custom_blog_menu' );

function custom_blog_menu( $args ) {
  if ( x_is_product() || x_is_product_index() || is_woocommerce() || is_cart() || is_checkout() ) {
    $args['theme_location'] = 'primary';
    $args['menu'] = 'Custom Menu';
  }
  return $args;
}

Hope it helps :slight_smile:

1 Like

Yes, perfect. Thank you.

1 Like

You’re most welcome.

Feel free to let us know if you have other question.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.