-
-
Save jameskoster/5133515 to your computer and use it in GitHub Desktop.
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 ); | |
function woo_rename_tabs( $tabs ) { | |
$tabs['description']['title'] = __( 'More Information' ); // Rename the description tab | |
$tabs['reviews']['title'] = __( 'Ratings' ); // Rename the reviews tab | |
$tabs['additional_information']['title'] = __( 'Product Data' ); // Rename the additional information tab | |
return $tabs; | |
} |
The above code appears to give the following error on products that do not have any additional info:
Warning: call_user_func() expects parameter 1 to be a valid callback, no array or string given in /home/mywebsite/public_html/wp-content/themes/striking_r/single-product/tabs/tabs.php on line 33
I'm guessing that it is trying to change the title of a tab which doesn't exist for products with no additional info added? Is there a way to add some sort of 'if tab exists' check to the additional_information tab renaming line?
Otherwise it works great, very useful, thanks :)
Cheers, James
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
global $product, $post;
if ( $post->post_content ) {
$tabs['description']['title'] = __( 'More Information' );
}
return $tabs;
}
My problem solved! Hope i code it the right way.
Thanks wussyboys
I altered your code, as I want to change the 'additional information' title:
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
global $product, $post;
if ( $post->post_content ) {
$tabs['additional_information']['title'] = __( 'Info.' );
}
return $tabs;
}
It fixes the warning message.
However this forces the the additional info (now correctly titled 'Info.') to be visible, and active on page load (even if empty of content).
Any tips to make this work and not force active state?
Should be something like
if ( !function_exists( 'rename_woocommerce_tab' ) ) {
function rename_woocommerce_tab( $tabs ) {
global $product;
if ( $product->has_attributes() || $product->has_dimensions() || $product->has_weight() ) $tabs[ 'additional_information' ][ 'title' ] = __( 'Extra Info', 'gettextdomain' );
return $tabs;
}
}
add_filter( 'woocommerce_product_tabs', 'rename_woocommerce_tab', 98 );
as @admench define $post (change it to $product as you are using woo products)
`
/========= Rename Tabs============/
add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
global $product, $post;
if ( $product->post_content ) {
$tabs['description']['title'] = __( 'Description' ); // Rename the description tab
$tabs['reviews']['title'] = __( 'Ratings' ); // Rename the reviews tab
$tabs['additional_information']['title'] = __( 'Specification' ); // Rename the additional information tab
}
return $tabs;
}
`
Solved my Problem. added an if condition either $product has the content of these tabs.
Guys, I was in this big mess with a page friend. She disabled whatever tab she want and gave me the warning. The problem was that the function was expecting something but it was disable. This worked for me.
`add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
if ( $tabs['description'] ) {
$tabs['description']['title'] = __( 'Descripción' );
}
if($tabs['reviews']){
$tabs['reviews']['title'] = __( 'Calificaciones' );
}
if( $tabs['additional_information'] ) {
$tabs['additional_information']['title'] = __( 'Información adicional' );
}
return $tabs;
}`
Hello all,
This great works for me in changing the tab name but it does not alter the Discription text just below it, just above the text from the product page. Please see picture if im not that clear. http://i204.photobucket.com/albums/bb44/ClassicMullet/discription%202_zps1rjiksnu.png
Im pretty new to all this so please bear with me. Thanks!
I get this error on some products, (some products do not show it, I can not find the reason why):
Notice: Undefined index: priority in E:\wamp\www\my-theme\wp-content\plugins\woocommerce\woocommerce-template.php on line 789