代码之家  ›  专栏  ›  技术社区  ›  Shaf

重命名Woocommerce单一产品页面中的描述选项卡

  •  3
  • Shaf  · 技术社区  · 7 年前

    我在函数中粘贴了这段代码。php,但它没有按预期重命名产品页选项卡( http://www.noushasasart.com/product/harsh-bark/ )

    function woo_remove_product_tabs($tabs) {
        unset($tabs['reviews']);    // Remove the reviews tab
        $tabs['description']['title'] = __('Additional Information');  // Rename the 
    
        description tab        
        return $tabs;
    }
    

    我如何解决这个问题?

    1 回复  |  直到 7 年前
        1
  •  5
  •   LoicTheAztec    7 年前

    您忘记了过滤器挂钩:

    add_filter( 'woocommerce_product_tabs', 'woo_customize_tabs', 100, 1 );
    function woo_customize_tabs( $tabs ) {
    
        unset($tabs['reviews']);    // Remove the reviews tab
    
        $tabs['description']['title'] = __( 'More Information' ); // Rename the description tab
    
        return $tabs;
    }
    

    代码进入函数。活动子主题(或主题)或任何插件文件中的php文件。


    (与您的评论相关) |重命名产品描述标题(在选项卡内):

    woocommerce_product_description_heading 按此方式过滤挂钩:

    add_filter( 'woocommerce_product_description_heading', 'rename_product_description_heading', 10, 1 );
    function rename_product_description_heading( $heading ) {
        return  __( 'Additional Information', 'woocommerce' );
    }
    

    代码进入函数。活动子主题(或主题)或任何插件文件中的php文件。

    所有代码都在Woocommerce 3+上测试并正常工作。


    Editing product data tabs