I am having trouble adding the category description for my products at the end of each description for each product at the 'description' tab beneath each item. So far, my function (at bottom) puts ALL category descriptions instead of the one category the product s actually in.
Here's the example of the category with description page.
Sample product page with description (Starting at: Stories Native American stories and legends have traditionally served... ...)
This is the code I am using to combine two functions. It works to add all category descriptions but I am trying to make it only show the one relevant description:
add_filter( 'the_content', 'customizing_woocommerce_description' );
function customizing_woocommerce_description( $content ) {
// Only for single product pages (woocommerce)
if ( is_product() ) {
// The custom content
$args = array( 'taxonomy' => 'product_cat' );
$terms = get_terms('product_cat', $args);
$count = count($terms);
// if ($count > 0) {
foreach ($terms as $term) {
/* echo $term->description;*/
$custom_content = '<p class="custom-content">' . __($term->description, "woocommerce").'</p>';
// Inserting the custom content at the end
$content .= $custom_content;
}
// }
}
return $content;
}
So far I am implementing the code in a non destructive php plugin for wordpress.