Woocommerce:删除"其他信息"标签

时间:2017-12-07 16:28:11

标签: php wordpress woocommerce hook-woocommerce

我想在本网站的产品页面上做两件事:https://lovesometea.com/product/green-coconut/

1)删除"其他信息"标签 2)添加属性"大小"高于产品说明

删除"附加信息"标签,我一直在关注:https://idevie.com/tutorials/how-to-make-woocommerce-product-attributes-more-prominent

所以这就是我所做的: 1)添加了自定义插件并将其激活 - http://code.tutsplus.com/tutorials/making-woocommerce-product-attributes-more-prominent--cms-25438

2)尝试删除"其他信息"通过编辑/ wp-content / plugins / woocommerce / templates / single-product / tabs中的tabs.php

/**
 * Removes the "Additional Information" tab that displays the product attributes.
 * 
 * @param array $tabs WooCommerce tabs to display.
 * 
 * @return array WooCommerce tabs to display, minus "Additional Information".
 */
function tutsplus_remove_product_attributes_tab( $tabs ) {

    unset( $tabs['additional_information'] );

    return $tabs;

}

add_filter( 'woocommerce_product_tabs', 'tutsplus_remove_product_attributes_tab', 100 );

这就是我被困的地方。我甚至尝试一起删除additional-information.php文件(在相同的标签文件夹中),并且仍然显示其他信息!

我尝试将上述代码放在tabs.php文件的三个不同区域,但对产品页面上的选项卡没有影响。

还有其他建议吗?也许最新的woocommerce版本有不同/更好的方法?

2 个答案:

答案 0 :(得分:1)

这对我删除标签很有用:

在functions.php中添加:

add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );

function woo_remove_product_tabs( $tabs ) {

    unset( $tabs['description'] );          // Remove the description tab
    unset( $tabs['reviews'] );          // Remove the reviews tab
    unset( $tabs['additional_information'] );   // Remove the additional information tab

    return $tabs;

}

要返回要在说明下显示的属性,我无法弄明白,所以我只是在说明中添加了尺寸

答案 1 :(得分:0)

也许您需要将优先级从100更改为98,如woocommerce documentation中所示,将代码放在functions.php文件中

add_filter( 'woocommerce_product_tabs', 'woo_remove_product_tabs', 98 );

function woo_remove_product_tabs( $tabs ) {

    unset( $tabs['additional_information'] );   // Remove the additional information tab

    return $tabs;

}
相关问题