How to Add a Custom Heading to the WooCommerce Product Description Section

In a recent Business Bloomer Club Slack thread, a WooCommerce user wanted to automatically add a heading to the “Description” section of product detail pages.

Rather than manually entering a heading for each product, they aimed to apply this globally in the WooCommerce template.

This can be achieved by using the woocommerce_product_description_heading filter, which allows you to customize or add headings to the description section across all products.

Step 1: Use the woocommerce_product_description_heading Filter

WooCommerce includes a filter called woocommerce_product_description_heading that lets you modify the default heading text for the description tab. By using this filter, you can customize the heading without manually adding it to each product description.

Here’s how to add an <h3> heading globally:

add_filter( 'woocommerce_product_description_heading', 'custom_product_description_heading' );

function custom_product_description_heading( $heading ) {
    // Customize the heading for the description tab
    return '<h3>Description</h3>';
}

Explanation of the Code

  1. Filter Application: This code hooks into the woocommerce_product_description_heading filter.
  2. Custom Heading: It overrides the default heading, replacing it with <h3>Description</h3> for consistency across all product description sections.

Step 2: Check the Theme Compatibility

Some themes, like Astra, may modify WooCommerce templates. If you don’t see the change reflected, ensure your theme isn’t overriding the description tab template or consult your theme documentation for compatibility with WooCommerce filters.

Conclusion

Using the woocommerce_product_description_heading filter is an efficient way to globally add a custom heading to the product description section, saving time and ensuring consistency. This approach keeps your product pages uniform and eliminates the need for manual edits across individual products.

Related content

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

Reply

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