php将多个页面写在一个页面,php – 将多个标签添加到WooCommerce单个产品页面

博主在尝试为WooCommerce店铺自定义产品标签时遇到问题,代码中移除了原有的描述、评论和附加信息标签,并尝试添加了三个新的标签:属性描述、数量定价和其它产品。然而,属性描述标签并未显示,且数量定价标签的描述未正常显示。博主已经检查并调整了代码,但问题依然存在。完整functions.php文件展示了代码实现。
摘要由CSDN通过智能技术生成

我想为WooCommerce添加三个自定义标签.我有下面的代码,其中两个显示,但由于某种原因,属性描述选项卡不显示在页面上.不仅数量定价选项卡不显示其描述.我试图将代码的不同部分移动到不同的位置,我已检查代码是否有错误或缺少部分.这是我能得到的尽可能接近.

我的过程基本上是删除我不想要的现有标签,然后按照我希望它们出现的顺序添加新标签.

我有一种感觉,我错过了一些东西.

这是我正在使用的代码:

// WooCommerce Tabs

// REMOVE EXISTING TABS

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;

}

// ADD ATTRIBUTE DESCRIPTION TAB

add_filter( 'woocommerce_product_tabs', 'woo_attrib_desc_tab' );

function woo_attrib_desc_tab( $tabs ) {

// Adds the Attribute Description tab

$tabs['attrib_desc_tab'] = array(

'title' => __( 'Desc', 'woocommerce' ),

'priority' => 100,

'callback' => 'woo_attrib_desc_tab_content'

);

return $tabs;

}

// ADD QUANTITY PRICING TAB

add_filter( 'woocommerce_product_tabs', 'woo_qty_pricing_tab' );

function woo_qty_pricing_tab( $tabs ) {

// Adds the qty pricing tab

$tabs['qty_pricing_tab'] = array(

'title' => __( 'Quantity Pricing', 'woocommerce' ),

'priority' => 110,

'callback' => 'woo_qty_pricing_tab_content'

);

return $tabs;

}

// ADD OTHER PRODUCTS TAB

add_filter( 'woocommerce_product_tabs', 'woo_other_products_tab' );

function woo_other_products_tab( $tabs ) {

// Adds the other products tab

$tabs['other_products_tab'] = array(

'title' => __( 'Other Products', 'woocommerce' ),

'priority' => 120,

'callback' => 'woo_other_products_tab_content'

);

return $tabs;

}

// ADD CUSTOM TAB DESCRIPTIONS

function woo_attrib_desc_tab_content() {

// The attribute description tab content

echo '

Description

';

echo '

Custom description tab.

';

}

function woo_qty_pricing_tab_content() {

// The qty pricing tab content

echo '

Quantity Pricing

';

echo '

Here\'s your quantity pricing tab.

';

}

function woo_other_products_tab_content() {

// The other products tab content

echo '

Other Products

';

echo '

Here\'s your other products tab.

';

}

编辑下面LoicTheAztec的回复,这是我的整个functions.php文件.我试过它有没有?>在底部:

add_theme_support( 'builder-3.0' );

add_theme_support( 'builder-responsive' );

function register_my_fonts() {

wp_register_style('googleFonts-OpenSans', '//fonts.googleapis.com/css?family=Open+Sans:400,300,700');

wp_enqueue_style( 'googleFonts-OpenSans');

}

add_action('wp_enqueue_scripts', 'register_my_fonts');

function sc_replacecolon( $content ){ return str_replace( '[sc:', '[sc name=', $content ); }

add_filter( 'the_content', 'sc_replacecolon', 5 );

/* WOOCOMMERCE */

add_filter( 'woocommerce_product_tabs', 'woo_custom_product_tabs', 100, 1 );

function woo_custom_product_tabs( $tabs ) {

// 1) Removing tabs

unset( $tabs['description'] ); // Remove the description tab

// unset( $tabs['reviews'] ); // Remove the reviews tab

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

// 2 Adding new tabs

//Attribute Description tab

$tabs['attrib_desc_tab'] = array(

'title' => __( 'Desc', 'woocommerce' ),

'priority' => 100,

'callback' => 'woo_attrib_desc_tab_content'

);

// Adds the qty pricing tab

$tabs['qty_pricing_tab'] = array(

'title' => __( 'Quantity Pricing', 'woocommerce' ),

'priority' => 110,

'callback' => 'woo_qty_pricing_tab_content'

);

// Adds the other products tab

$tabs['other_products_tab'] = array(

'title' => __( 'Other Products', 'woocommerce' ),

'priority' => 120,

'callback' => 'woo_other_products_tab_content'

);

return $tabs;

}

// New Tab contents

function woo_attrib_desc_tab_content() {

// The attribute description tab content

echo '

Description

';

echo '

Custom description tab.

';

}

function woo_qty_pricing_tab_content() {

// The qty pricing tab content

echo '

Quantity Pricing

';

echo '

Here\'s your quantity pricing tab.

';

}

function woo_other_products_tab_content() {

// The other products tab content

echo '

Other Products

';

echo '

Here\'s your other products tab.

';

}

?>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值