dongzhan8620 2014-09-06 04:44
浏览 132

针对特定产品的Woocommerce自定义导航菜单

I am using Woocommerce plugin for my online services(not physical products) Just one of my service's page here: http://www.vaservicesph.com/product/whiteboard-animation-service-basic/

I'm also using Optimizepress theme on the site.

Here's what optimizepress have on header section(it's using the blog template for the woocommerce stuffs):

a. An option to add a nav menu at the top

b. An option to add a nav menu alongside the logo

Here's a screenshot of option -> screencast.com/t/zsrlLec9CH

And they will be located here on the page: -> screencast.com/t/djtqjaZZ5

*Please add http on my screencast links if it'll not work(sorry about this, I'm new to stackoverflow and need more points to post more links).

So if I enable a menu for my blog, they will appear on the top(alongside logo) and will also be used for my product page template(which is not good).

What I'd like to do is use a different menu for these specific service only. So whiteboard services will only have nav menus about whiteboard services related pages(that I specify).

How can I do this? Hope I'm clear to my question. Thank you!

-- Clint

  • 写回答

2条回答 默认 最新

  • dream04110 2014-09-07 11:49
    关注

    You could register a second menu in your functions.php:

    register_nav_menu( 'product', 'Product Menu' );
    

    And then wherever you are displaying the main menu (possibly header.php) you can adjust it to use conditional logic to display the product menu in one case and your theme's primary menu in all others. For example:

    if( function_exists('is_product') && is_product() ){
      wp_nav_menu( array( 'theme_location' => 'product' ) );
    } else {
      wp_nav_menu( array( 'theme_location' => 'primary' ) );
    }
    

    This isn't meant to be a complete answer, but hopefully it gets you going in the right direction. You can use any kind of conditional logic that you'd like. Checking product categories might be a good idea if you put all your whiteboard products in the same category.

    评论

报告相同问题?

悬赏问题

  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建
  • ¥15 数据可视化Python
  • ¥15 要给毕业设计添加扫码登录的功能!!有偿
  • ¥15 kafka 分区副本增加会导致消息丢失或者不可用吗?
  • ¥15 微信公众号自制会员卡没有收款渠道啊
  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘