How to display an Icon on Single Page if a Product Has A Specific Tag
-
Hey Support Team/Community,
Hope you are well. I’m stuck with one of my clients’ sites. I would like to display feature icons. This means that if a product has a specific tag it would = display a specific icon. I wasn’t sure what is the best approach for this is.. I have a custom elementor site/not themed so I thought I should do it over the small summary..
Could you guys help to complete it? Not sure where to end it… I know how to display all the icons if there is more than one tags.. Initially I thought about lists/arrays but not sure now..
Here is my nooby code:
function magik_custom_text( $post_excerpt ) { $socialcontribution = ''; $naturalingredients = ''; $veganfriendly = ''; $plasticfree = ''; $recycleable = ''; $sustainable = ''; $handmade = ''; $madeinuk = ''; $refillable = ''; $organic = '<i class="fab fa-500px"></i> '; $thelist = array(); if ( has_term( 'organic', 'product_tag' ) ) { $thelist[] = $organic; return $thelist[0] . '<br><br>' . $post_excerpt; } elseif ( has_term( 'refillable', 'product_cat' ) ) { return $refillable . '<br><br>' . $post_excerpt; } else { return $content . '<br><br>' . $post_excerpt; } } add_filter('woocommerce_short_description', 'magik_custom_text', 10, 1);
Every help helps… Thank you ??
Oliver
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘How to display an Icon on Single Page if a Product Has A Specific Tag’ is closed to new replies.