Show product description on shop page IF it has this categories
-
Hi!
I wanted to show my products description under the title on shop page, which i’ve done like this on functions.php and it works great:
add_action( 'woocommerce_after_shop_loop_item', 'woo_show_excerpt_shop_page', 5 ); function woo_show_excerpt_shop_page() { global $product; ?> <div itemprop="description"> <?php echo apply_filters( 'the_content', $product->post->post_content ) ?> </div> <?php }
And now I would like to show that ONLY if the product is from a certain category (could be in 12 of them, but not in the rest), in which i’ve tried to add this but it is not working:
if ( is_product() && has_term( 'my_category') ) { add_action( 'woocommerce_after_shop_loop_item', 'woo_show_excerpt_shop_page', 5 ); function woo_show_excerpt_shop_page() { global $product; ?> <div itemprop="description"> <?php echo apply_filters( 'the_content', $product->post->post_content ) ?> </div> <?php } }
If I am able to do it someway I would really appreciate some help with it, and also adding more possible categories in the if condition (as on OR not AND).
Thank you in advanced!
The page I need help with: [log in to see the link]
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Show product description on shop page IF it has this categories’ is closed to new replies.