I'm using Wordpress with WooCommerce, on the single product page I want to check if one of the product member categories is a member of a parent 'Brands' and if it is display the description from that brand member category.
I've done the following, however it outputs all the categories the product is a member of;
<?php $terms = get_the_terms( $post->ID, 'product_cat' );
if($terms){
foreach($terms as $term){
$category_parent_id = $term->parent;
$category_parent = get_category($category_parent_id);
$category_description = $term->description;
//if(($category_parent = "Brands")){ // THIS DOESNT WORK OUTPUTS ALL CATS
if( "Brands" == $category_parent ){ // THIS DOESNT WORK EITHER, OUTPUTS NO RESULTS
$category_name = $term->name;
$category_thumbnail = get_woocommerce_term_meta($term->term_id, 'thumbnail_id', true);
$image = wp_get_attachment_url($category_thumbnail); ?>
Do Some HTML Stuff Here
<?php }
}
} ?>
Brands >
Brands > Brand1 >
Brands > Brand1 > Product
Brands > Brand2 >
Brands > Brand2 > Product
Brands > Brand9999 >
Brands > Brand9999 > Product
If 'Product' is member of 'Brandx' which is a member of 'Brands' then output the description from the 'Brandx' category.