WordPress企业主题定制/开发/优化

修改WooCommerce产品描述Tab标题与删除评论tab选项卡

首页 » WORDPRESS教程 » 修改WooCommerce产品描述Tab标题与删除评论tab选项卡

How to Change the WooCommerce Product Description Tab Title and Heading

Let’s edit the WooCommerce default product page to reflect the following global changes:

1. Change the product description tab title from “Description” to the product name;

2. Change the product description tab heading from “Product Description” to “Reviews;” and

3. Remove the existing Reviews tab.

Here is an example of the WooCommerce default product page from a site using the Twenty Fourteen theme. We’ll be changing the tab section at the bottom.

Here are the three code snippets to add to your functions.php file (read How to Properly Add WooCommerce Custom Code for alternatives):

 

// Change the product description tab title to the product name
add_filter( 'woocommerce_product_tabs', 'cb_change_product_description_tab_title' );
function cb_change_product_description_tab_title( $tabs ) {
global $post;
if ( isset( $tabs['description']['title'] ) )
$tabs['description']['title'] = $post->post_title;
return $tabs;
}

// Change the product description tab heading
add_filter( 'woocommerce_product_description_heading', 'cb_change_product_description_tab_heading' );
function cb_change_product_description_tab_heading( $title ) {
global $post;
return 'Reviews';
}

// Remove the default review tab
add_filter( 'woocommerce_product_tabs', 'cb_remove_reviews_tab' );
function cb_remove_reviews_tab($tabs) {
unset($tabs['reviews']);
return $tabs;
}

 

To change the product description tab heading to something other than “Reviews,” substitute what you want in place of ‘Reviews’ at the end of the second code snippet.

Happy coding!

分类与标签:

WORDPRESS教程

相关项目

  • WordPress外贸企业主题

  • 最近更新

  • 热门标签