WooCommerce is_product_category() not working


I’m trying to add text to the product short description by category.

So for example, for all Cake Toppers, I want to add to the bottom of the short description to show “This is a cake topper”. For all products which are not cake toppers, I want to show the text “Not a cake topper”.

This is the code I’m using:

add_action( ‘woocommerce_single_product_summary’, ‘product_short_description_by_category’, 20 );

function product_short_description_by_category() {
if( is_product_category(‘cake-toppers’) ){
echo ‘

A cake topper

echo ‘



But all products, including cake topper, show “THIS IS NOT A CAKE TOPPER”.

What am I doing wrong here? “cake-toppers” is the slug for the category name.

Site at: http://wendyw11.sg-host.com/product/two-wild-cake-topper/

Any help is greatly appreciated!

Wendy 4 months 0 Answers 26 views 0

Leave an answer