How to display Woocommerce category description

I have regular Wordpress code to display a category description:

<?php echo category_description( $category_id ); ?> 

But how can I display a description of the Woocommerce category? @@ After one of the suggestions for comments, I added:

  <?php if ( have_posts() ) { while ( have_posts() ) { the_post(); global $post, $product; $categ = $product->get_categories(); $term = get_term_by ( 'name' , strip_tags($categ), 'product_cat' ); echo $term->description; } // end while } // end if ?> 

However, it does not work.

+7
source share
4 answers
 $args = array( 'taxonomy' => 'product_cat' ); $terms = get_terms('product_cat', $args); $count = count($terms); if ($count > 0) { foreach ($terms as $term) { echo $term->description; } } 

Edit for last answer:

  <?php global $post; $args = array( 'taxonomy' => 'product_cat',); $terms = wp_get_post_terms($post->ID,'product_cat', $args); $count = count($terms); if ($count > 0) { foreach ($terms as $term) { echo '<div style="direction:rtl;">'; echo $term->description; echo '</div>'; } } ?> 
+11
source

You can display a description of the category category -

use this code -

 <?php global $post, $product; $categ = $product->get_categories(); $term = get_term_by ( 'name' , strip_tags($categ), 'product_cat' ); echo $term->description; ?> 
+2
source

the_archive_description() worked for my purposes when other (more complex) solutions did not work.

Optional parameters can be added before and after the line.

+1
source

The main answer for some reason displayed more than one description for me.

The answer below solved this for those who have the same problem:

fooobar.com/questions/7442291 / ...

0
source

Source: https://habr.com/ru/post/955497/


All Articles