Skip to content

Instantly share code, notes, and snippets.

@rashmimalpande
Created September 25, 2017 10:26
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 rashmimalpande/5bd6edc368b947d8c89e0e38e17a2494 to your computer and use it in GitHub Desktop.
Save rashmimalpande/5bd6edc368b947d8c89e0e38e17a2494 to your computer and use it in GitHub Desktop.
public function add_custom_html() {
global $post;
$product_id = $post->ID;
$categories = get_the_terms( $product_id, 'product_cat' );
if( empty ($categories)){
return;
}
//add image url in the src attribute
$content = '<img src="sizing-mens.png" width="500" height="200">';
foreach($categories as $cat){
if( 'men' == $cat->slug ) {
echo $content;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment