Show Category Names and Descriptions on WooCommerce Product Pages

Quick Summary

  • Loop over wp_get_post_terms for the product_cat taxonomy and print each category name, followed by its description when one is set.
  • Place it in a single product template such as a child theme copy of content-single-product.php, since it reads the current post ID.
  • Parent categories only appear when ticked on the product, and values print as stored, so consider esc_html and wp_kses_post in production.

This snippet shows category descriptions on the WooCommerce single product page: each category of the current product, followed by its description if it has one. It’s handy when your categories carry useful text, such as sizing notes or material info, that you want to repeat on every product in that category.

Place it in a template that renders the single product, for example a copy of content-single-product.php in the woocommerce folder of your child theme. It has to run inside the product loop, because it reads the ID of the current post.

PHP
<?php 
    foreach( wp_get_post_terms( get_the_id(), 'product_cat' ) as $term ){
        if( $term ){
            echo $term->name . '<br>'; // product category name
            if ($term->description)
                echo $term->description . '<br>'; // Product category description
        }
    }
?>

How it works

  • wp_get_post_terms() returns the product_cat terms (WooCommerce product categories) assigned to the product whose ID comes from get_the_id(). With 'fields' => 'names', the same function adds category names to WooCommerce order details.
  • For each category, the loop prints $term->name followed by a line break.
  • If the category has a description (added under Products > Categories), $term->description follows on the next line. Categories without one only show their name.
  • The list only shows categories assigned to the product. A parent category doesn’t appear unless it’s ticked on the product too.

To show product tags instead, change product_cat to product_tag. The code prints the values as WordPress stores them, so in a production theme consider wrapping the name in esc_html() and the description in wp_kses_post(), and replacing the <br> tags with your own markup and CSS classes.

For product pages designed around your categories and their content, see my WooCommerce development services.

Share on X (opens in a new tab) Share on LinkedIn (opens in a new tab) Share on Facebook (opens in a new tab)

ChatGPT (opens in a new tab) Claude (opens in a new tab) Gemini (opens in a new tab) Perplexity (opens in a new tab) Grok (opens in a new tab)

More Insights

See More