Don’t need get_term_children()
at all. Just loop through get_the_terms()
to get what’s needed.
global $post;
$brands_id = get_term_by('slug', 'brands', 'product_cat');
$terms = get_the_terms($post->ID, 'product_cat');
foreach ($terms as $term) {
if($term->parent === $brands_id->term_id) {
echo $term->name;
break;
}
}
Related Posts:
- Woocommerce get category image full size
- Programmatically create product category and add thumbnail in woocommerce
- Set post categories to include parents when setting child category
- Get WooCommerce product category list in functions.php
- Restrict retrieved terms by category?
- Categories and Tags Conflict after Woocommerce Installation
- Is There a Difference Between Taxonomies and Categories?
- Display All Products by Category with WooCommerce
- Check if a post is in any child category of a parent category
- How to export and import taxonomies (category, tag and/or custom taxonomy) and their terms
- Retrieve Product category ‘NAME’ by product category ID – WooCommerce?
- get_terms vs. get_categories: does it matter?
- Order get_terms() By Custom Field
- Control term order on a per-post basis
- Fixing category count
- How can I get category ID by category name?
- get_terms name__like list categories according to letter
- Elegant way to add parent categories?
- How can I select a primary category?
- How to order the get_categories result
- Reflect nested categories in appearance > menus
- Create product category and keyword search form in woocommerce? [closed]
- Send an email when custom post type category is changed
- Are Categories, Tags and Custom Taxonomies any different in regards to SEO?
- Excluding posts from a category but only if they’re not in multiple categories
- Update term count using a callback function
- Remove child products from woocommerce category page [closed]
- Get terms that are associated with products from current category
- How do I edit pre_get_post for the category the user is currently in?
- Display Categories Assigned to a WooCommerce Product
- Does WordPress Offer a Way to Find All of the Categories that Don’t Have Children?
- Add custom taxonomy terms to WordPress menu dynamically & append #slug to url
- Removed slug from CPT, now How/where do I hook the filter to the taxonomy term archive pages link?
- Display WooCommerce product categories in a 4 columns custom menu [closed]
- Getting the sub category
- How to select product category while adding new product in woocommerce? [closed]
- Hide uncategorized products from the shop page
- Action hooks returning old category instead of new category
- Update wordpress post terms programatically
- Display empty taxonomy terms with get_terms()
- Remove word “Category” from WooCommerce product page [closed]
- Get a list of Terms for a specific category
- Filtering search results
- WooCommerce change category url and product base
- get_terms won’t display product_cat or any other custom taxonomies when specified
- Output link to category from WP_Query loop of woocommerce products
- display woocommerce all category title on home page
- When to use ‘get_category_by_path’ vs. ‘get_term_by’ to get category object from `get_query_var( ‘category_name’ )`?
- Add Icons to the Product Category Sidebar Widget WooCommerce
- Add Product categories to WordPress menu without losing hierarchy
- Display “add to cart” button on every listing in product category page?
- How to get product count with respect to categories in WooComerce
- Custom page for WooCommerce’s /product-category/
- Getting categories id for all products in cart
- Get woocommerce catogry
- List Terms in Category
- get_cat_ID() not wokring
- How do I get a list of all categories that a given user has written blog posts for?
- Display child categories in WooCommerce
- WooCommerce duplicate sub categories and product slugs
- WooCommerce IF statements not working
- Linking products to categories
- Woocommerce category show subcategories only/omit posts for specific category
- Warning: sizeof (): Parameter must be an array or an object that implements Countable, On products pages
- Omit specific product categories from WooCommerce shortcode
- How to get data about category in category.php
- products nested by subcategories in a current category archive
- WC 3.x Get categories from variable product of the cart
- Multiple Domain Names – One WP Install (non-Multisite) – Default Each Domain name to Product Category WooCommerce
- Limit number of terms that a custom taxonomy can save per custom post type
- Inserting Category programmatically
- How can i insert term in a specific language of Polylang?
- Hide woocommerce category name from specific pages
- Hide woocommerce category name from specific pages
- need to add custom field in more products
- Why does the argument list_only do on Walker_Category_Checklist::start_el?
- How to redefine the sorting of product categories by menu_order?
- Pagination not visible on woocommerce’s category page
- Pagination is not working properly in Product Category/Tag pages
- Best way of getting WooCommerce category path
- How to recreate a copy of a product category in WooCommerce? [closed]
- Get parrent category name
- Sorting category products not working
- Remove product category placeholder image (Woocomerce)
- Categories for each brands
- Change thumbnail image depending product category
- Unwanted Duplicate Product Categories in WooCommerce
- Woocommerce custom category pages
- Customize WordPress widget – Product Category
- WordPress/Woocommerce only show category in shop to a single role
- WooCommerce – How to show specific category first-rest of products-specific category last
- Woocommerce custom category page with pagination [closed]
- Display Posts Loop for each parent and for each Child
- Is There a Difference Between Taxonomies and Categories?
- Get posts from specific taxonomy term
- Get posts under a category with SQL
- Getting category URL with hyphens, not spaces
- get_terms function not returning anything
- Display custom taxonomy attached to the post on post single page
- Categories are not listing their respective products