How to test If a post has a particular term


I want to display a different description for a post if it belongs to a specific product category in a filter.

I’ve used the code below code to add the code but it is displaying for all products:

function herara_filter_short_description( $desc ){
    global $product;
    if ( is_single( $product->id ) ) {
        $desc = '<span class="sku_wrapper">SKU: <span class="sku">'. $product->get_sku() .'</span></span></BR><span class="material_wrapper">MATERIAL: <span class="material">'. $product->get_sku() .'</span></span>';
    return $desc;
add_filter( 'woocommerce_short_description', 'herara_filter_short_description' );
Ahmad Darwish 4 months 0 Answers 7 views 0

Leave an answer