categories - Add category description on product page (Woocommerce)

I'm using Woocommerce as a catalog for a website.I would like to show the category description in every product pag

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!

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!

Share Improve this question asked Mar 7, 2019 at 15:48 BeatriceBeatrice 11 silver badge1 bronze badge 1
  • 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 Commented Mar 8, 2019 at 4:28
Add a comment  | 

2 Answers 2

Reset to default 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.

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);

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744865860a4597973.html

相关推荐

  • categories - Add category description on product page (Woocommerce)

    I'm using Woocommerce as a catalog for a website.I would like to show the category description in every product pag

    1天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信