0

I'm using Woocommerce as a catalog for a website.

I would like to show the category description in every product page.

It's that possibile by editing my theme or maybe with a plugin? I can't find anything.

Thanks!

  • Are you want to show the category description in every product page means on product detail page??? and also share a screenshot of that so I can help you. – Tanmay Patel Mar 8 at 4:28
0

This will display the categories.

<?php
    $args = array('taxonomy' => 'product_cat');
    $terms = get_terms('product_cat', $args);
    $count = count($terms); 

    if ($count > 0) {
        foreach ($terms as $term) {
            echo '<p>' . $term->description . '</p>';
        }
    }
?>

Where you put it depends on your theme. In your theme or child theme you need to create these folders woocommerce > single-product > meta.php.

You will most likely need to edit the above code for your needs but it should give you an idea.

0

You can simply add this to your functions.php file of your child theme.

function display_product_category_descriptions(){
  global $product;

  $terms = get_the_terms( $product->get_id(), 'product_cat');

  foreach ($terms as $term) {
    echo '<p>' . $term->description  . '</p>';
  }
}
add_action( 'woocommerce_single_product_summary', 'display_product_category_descriptions', 45);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.