Skip to content

Instantly share code, notes, and snippets.

@rashmimalpande
Last active September 25, 2017 13:37
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/014e0bccdb9869ccf970266f92a98174 to your computer and use it in GitHub Desktop.
Save rashmimalpande/014e0bccdb9869ccf970266f92a98174 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;
}
$content = "
<table>
<tr>
<th></th>
<th>Small</th>
<th>Medium</th>
<th>Large</th>
</tr>
<tr>
<td>USA</td>
<td>2-4</td>
<td>6-8</td>
<td>9-12</td>
</tr>
<tr>
<td>UK</td>
<td>4-6</td>
<td>8-10</td>
<td>12-14</td>
</tr>
<tr>
<td>India</td>
<td>2-4</td>
<td>6-8</td>
<td>10-12</td>
</tr>
</table>
";
foreach( $categories as $cat ){
if( 15 == $cat->term_id ) {
echo $content;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment