【问题标题】:WooCommerce: Removing breadcrumbs for single products not workingWooCommerce:删除单个产品的面包屑不起作用
【发布时间】:2019-07-02 10:40:10
【问题描述】:

我想删除除产品类别和单个产品之外的所有页面的面包屑。不幸的是,我的条件语句不起作用。谁能告诉我我做错了什么?

我尝试通过条件回显一些文本,一切正常。也可以在没有任何条件的情况下删除面包屑。

    add_action( 'init', 'wc_remove_storefront_breadcrumbs');
    function wc_remove_storefront_breadcrumbs() {
      if ( !is_product() || !is_product_category() ){
         remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10 );
      }
    }

有了这段代码,面包屑就随处可见了。

【问题讨论】:

    标签: woocommerce breadcrumbs storefront


    【解决方案1】:

    我更改了 add_action 中的标签和优先级,现在可以正常工作了。

    add_action( 'storefront_before_content', 'wc_remove_storefront_breadcrumbs', 0);
    function wc_remove_storefront_breadcrumbs() {
      if( !is_product() ) {
       remove_action( 'storefront_before_content', 'woocommerce_breadcrumb', 10 );
      }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-02-11
      • 1970-01-01
      相关资源
      最近更新 更多