Shop Page - Display Product's Categories within Description
I've been searching the forum widely but unfortunately due to the keywords involved I'm getting multiple different discussions. So to be specific I'm not talking about simply displaying "Categories" on a page but instead to show each products individual categories in which they were assigned to on the shop page. I'm looking to accomplish this https://www.teacherspayteachers.com/Browse/Grade-Level/Pre-K in which each product's categories are below the product's description.
I welcome any and all suggestions!
Comments
global $product,$post;
echo $product->post->post_excerpt;
$subject_categ = $product->get_categories();
echo '<div>Subjects:'.$subject_categ.'</div>';
$brands_id = get_term_by('slug', 'subjects', 'product_cat');
$terms = get_the_terms($post->ID, 'product_cat');
foreach ($terms as $term) {
if($term->parent === $brands_id->term_id) {
echo '<div>Subjects2:'.$term->name.'</div>';
break;
}
}
}