Skip to content

Instantly share code, notes, and snippets.

@xlawok
Last active June 17, 2020 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xlawok/079603e2a9ec67927055aa058d7a3504 to your computer and use it in GitHub Desktop.
Save xlawok/079603e2a9ec67927055aa058d7a3504 to your computer and use it in GitHub Desktop.
woocommerce add custom badge on image (based on tag/category) of related products
// ADD NOWOŚĆ TAG ONA ZDJĘCIE PRODUKTÓW POWIĄZANYCH
add_action('woocommerce_before_shop_loop_item_title','show_novelty_on_related_products',11);
function show_novelty_on_related_products(){
global $product;
if(is_product()){
if( has_term( array( 'Nowości' ), 'product_tag' ,$product) ) {
echo '<span class="novelty">Nowość!</span>';
}
}
else return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment