Woocommerce Extra Tabs (Hook)

woocommerce extra tabs

Are you looking to add an extra tab on your WooCommerce product page? This guide will show you exactly how to customize your store’s product pages with an additional tab. With just a few clicks, you can increase user engagement and take full advantage of the WooCommerce platform. Read on to learn more about why adding this extra tab is so beneficial and how to get started.

We are going to add an extra tab to the WooCommerce product page template by utilizing hooks. This will allow you to add custom content to your product pages without directly modifying the core WooCommerce template files. Instead, we will be working with the functions.php file of your child theme or a custom plugin, and the single-product.php file.

To achieve this, follow the steps below:

Step 1: Add a new custom tab to the product page

Open the functions.php file of your child theme or custom plugin and add the following code:

function custom_add_extra_tab($tabs) {
    $tabs['custom_tab'] = array(
        'title' => __('Custom Tab', 'text-domain'),
        'priority' => 50,
        'callback' => 'custom_tab_content'
    return $tabs;
add_filter('woocommerce_product_tabs', 'custom_add_extra_tab', 98);

his code snippet adds a new tab to the product page called “Custom Tab” by hooking into the ‘woocommerce_product_tabs’ filter. The ‘custom_tab_content’ function, which we will create in the next step, will be used to display the content of this tab.

Step 2: Define the content of the custom tab

In the same functions.php file, add the following code:

function custom_tab_content() {
    global $product;
    $custom_tab_content = get_post_meta($product->get_id(), '_custom_tab_content', true);
    echo '<div class="custom-tab-content">';
    echo apply_filters('the_content', $custom_tab_content);
    echo '</div>';

This function retrieves the custom tab content from the product’s metadata and displays it within a div container. You can modify this function to display any content you like.

Step 3: Add custom tab content to the product

To add content to the custom tab, you can either use the default WordPress custom fields or create a custom meta box for the product edit screen. In this example, we’ll use the default custom fields.

  1. Go to the product edit screen for the desired product in your WordPress admin area.
  2. Scroll down to the “Custom Fields” meta box. If you don’t see it, click on “Screen Options” at the top right corner of the screen and make sure “Custom Fields” is checked.
  3. Click on “Enter new” and enter “_custom_tab_content” as the Name and your desired content as the Value.
  4. Click “Add Custom Field” and update your product.

Now, when you visit the product page, you should see the new custom tab with your added content. If you want to add custom content to other products, simply repeat Step 3 for each product.

WooCommerce Development Services

Are you looking for a WooCommerce developer to help make the changes your store needs? Look no further! Contact us today and one of our experienced WooCommerce developers will work with you to customize your product page in no time. With our help, you can experience all the benefits that come with adding an extra tab to your WooCommerce product page, so don’t wait any longer and get started now!

Josh Morley

I have been designing & marketing websites since 2013. I specialize not just in WordPress web design but also in online marketing. SEO, PPC, keyword research, link-building and most recently on lead acquisition for local businesses.

Leave a Reply

Your email address will not be published. Required fields are marked *