如何删除woocommerce标签? [英] How to remove woocommerce tab?

查看:24
本文介绍了如何删除woocommerce标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们 woocommerce 商店中的产品不需要任何默认选项卡,因此我设法禁用它们,因为我只需要在产品下方添加产品描述,而我想保留实际描述,我相信标签本身是多余的,因为没有任何其他标签.

the products in our woocommerce shop don't need any of the default tabs so I have managed to disable them being that I only need to have the product description below the product however, while I want to keep the actual description, I believe the tab itself is redundant since there aren't any other tabs.

基本上,我想删除标签的 &标题完全但保留其下方的内容框而不修改 woocommerce 核心 php 模板文件.有没有办法向我的 WordPress 主题的functions.php 添加过滤器?

Basically, I want to remove the tab's & title altogether but keep the content box below it without modifying the woocommerce core php template file. Is there a way to add a filter to my WordPress theme's functions.php?

function woocommerce_default_product_tabs( $tabs = array() ) {
    global $product, $post;

    // Description tab - shows product content
    if ( $post->post_content ) {
        $tabs['description'] = array(
            'title'    => __( 'Description', 'woocommerce' ),
            'priority' => 10,
            'callback' => 'woocommerce_product_description_tab'
        );
    }

推荐答案

虽然 CSS 很棒,但如果样式表无法正确加载,您最终可能会向某人显示无意义的选项卡.正如您所提到的,最好在加载(服务器端)之前使用过滤器删除内容.

While CSS is great, if the stylesheet doesn't load correctly, you could end up showing someone tabs without meaning to. It is best to remove the content before loading (server side), by using a filter, as you had mentioned.

有关取消设置数据选项卡的信息,请参阅 Woothemes 提供的以下代码.
EDIT 放在您的主题内的functions.php 文件中.

See code below as provided from Woothemes for unsetting data tabs.
EDIT Place within the functions.php file inside your theme.

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;
}

EDIT 正如@BasvanDijk 所指出的要完全删除,您可以使用以下内容

EDIT As noted by @BasvanDijk To remove altogether, you can use the following

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

这篇关于如何删除woocommerce标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆