Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Frontend Snippets][Editing product data tabs] Renaming product data tabs
/**
* Rename product data tabs
*/
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;
}
@2xUeL

This comment has been minimized.

Copy link

@2xUeL 2xUeL commented May 10, 2019

This code seems to be causing a problem. It seems to be making it so the Additional Information tab shows up on a product page even when there is no additional information for that product. If I delete the code from my functions doc, the tab goes away on the product pages that have no additional information.

@BenjaminLaschkar

This comment has been minimized.

Copy link

@BenjaminLaschkar BenjaminLaschkar commented Nov 21, 2019

Work like a charm, thanks for sharing !

@micarner

This comment has been minimized.

Copy link

@micarner micarner commented May 21, 2021

@2xUeL It's been a hot minute, but you may need to check first if the array element is null or not. I think by setting the title, it could create the element when it did not exist, resulting in the tab appearing on the front end.

@spectralevolution

This comment has been minimized.

Copy link

@spectralevolution spectralevolution commented Aug 13, 2021

I'm newer at coding, so I hope this is an easy fix and I'm just being silly, but I am having trouble finding where to change the "h2" element that is auto-generated within the tab. I renamed "Additional Information" to "Product Data" but it still generates the text "Additional Information" in the body of the tab despite the title being changed in the tab itself. Image for clarification.

image

Thanks in advance if anyone can help me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment