我如何为每个WooCommerce产品类别创建不同的菜单?

请帮我有关Wordpress的提示,

我也创建了9个菜单, 也创建了9个WooCommerce类别, 但是我不知道如何在各自的WooCommerce产品类别中调用每个菜单。

产品>分类” class=”wp-image-63130″ src=”http://www.srcmini02.com/wp-content/uploads/2020/05/TyDYV.png”>

我使用Themeforest中的AVADA主题, 但是我的主题让我只为所有WooCommerce类别设置一个菜单:

AVADA主题选项

但是我必须为每个WooCommerce产品类别使用不同的菜单。

菜单类别01

#1


这是我发现的可以帮助你的解决方案:

你必须通过将archive-product.php复制到yourtheme / woocommerce / archive-product.php来覆盖woocommerce插件文件夹中的归档产品模板。编辑文件, 并在开头(或菜单需要显示的任何地方)添加以下代码:

<?php 

if ( is_tax( 'product_cat', 'category1' )) {
    wp_nav_menu( array( 'theme_location' => 'menu1' ) ); 
}

elseif ( is_tax( 'product_cat', 'category2' )) {
    wp_nav_menu( array( 'theme_location' => 'menu2' ) ); 
}

else ( is_tax( 'product_cat', 'category3' )) {
    wp_nav_menu( array( 'theme_location' => 'menu3' ) ); 
}

?>

当我们进入属于类别category1的产品页面时, 将显示menu1。

当我们进入属于类别category2的产品页面时, 将显示menu2。

来源:

https://www.srcmini02.com/63129.html

微信公众号
手机浏览(小程序)

Warning: get_headers(): SSL operation failed with code 1. OpenSSL Error messages: error:14090086:SSL routines:ssl3_get_server_certificate:certificate verify failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(): Failed to enable crypto in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57

Warning: get_headers(https://static.shanhubei.com/qrcode/qrcode_viewid_41980.jpg): failed to open stream: operation failed in /mydata/web/wwwshanhubei/web/wp-content/themes/shanhuke/single.php on line 57
0
分享到:
没有账号? 忘记密码?