Add custom taxonomy under the category title

I’ve added a custom taxonomy to my product category page in the admin. I can call the custom field using the following:

$queried_object = get_queried_object();
$t_id = $queried_object->term_id;

$term_meta =  get_option( "taxonomy_$t_id" );
echo $term_meta['custom_term_meta'];

It describes the category. For example, if I added a title for a particular product category named “Address Labels” I would add a description in my custom taxonomy like “Comparable to Avery….”.

How can I get that description (custom taxonomy) to display under the product category title that I added it to in the shop ?

I tried hardcoding it (I know it is bad but I was trying to work backwards to see what hook to use or if I was doing it right) and added the above code to content-product_cat.php under the woocommerce_after_subcategory_title hook and it displays that custom taxonomy BUT not under the product category I added it to, but under all of it’s sub categories.

Please help! I have been working on this for days.

1 Answer
1

I FINALLY figured it out. Phew. Answer is as follows:

add_action( 'woocommerce_after_subcategory', 'my_add_cat_description', 12);
function my_add_cat_description ($category) {
$cat_id=$category->term_id;
$prod_term=get_term($cat_id,'product_cat');
$term_meta =  get_option( "taxonomy_$cat_id" );
echo '<div class="cat_desc">'.$term_meta['custom_term_meta'].'</div>';
}

I hope this saves someone some time.

Leave a Comment