I just realised
I already have the parent from here $category = $_GET[‘category’];
So I changed my code:
<td class="custom-cat"> <span class="term">
<?php echo $category; ?>
</span></td>
<td class="custom-sub-cat"> <span class="term">
<?php
$terms = get_the_terms( get_the_ID(), 'custom-category' );
foreach ( $terms as $term ){
if ( $term->parent ==! 0 ) {
echo $term->name;
}
}
?>
</span></td>
As I only have one parent and one child for each taxonomy the above works fine for me as a work around.
Related Posts:
- Order get_terms() By Custom Field
- How can I select a primary category?
- Are Categories, Tags and Custom Taxonomies any different in regards to SEO?
- Removed slug from CPT, now How/where do I hook the filter to the taxonomy term archive pages link?
- Display empty taxonomy terms with get_terms()
- Get a list of Terms for a specific category
- Limit number of terms that a custom taxonomy can save per custom post type
- Allow user to set custom order to a list of custom taxonomies?
- Get posts from specific taxonomy term
- Display custom taxonomy attached to the post on post single page
- Ive got a term (get_term_by) but now I want to filter it by a category it is in?
- Get Categories Where Taxonomy Equals ‘n’
- Showing HTML if Post is In Certain Taxonomy Term
- Post to inherit custom category background image from parent
- List taxonomy terms assigned to a post in hierarchical view
- Get WooCommerce product category list in functions.php
- Display List of Categories Within a Custom Taxonomy
- List Terms by category
- Order get_terms using a Custom Field
- get_terms vs. get_categories: does it matter?
- Woocommerce get category image full size
- How to Change the Categories Order in the Admin Dashboard?
- Control term order on a per-post basis
- Fixing category count
- Combine two taxonomies in a hierarchical tree
- Elegant way to add parent categories?
- Display all posts in category, with specific tag posts at top
- Send an email when custom post type category is changed
- I want to order categories based upon the latest post time
- Excluding posts from a category but only if they’re not in multiple categories
- How to convert regular categories to custom taxonomy?
- Update term count using a callback function
- Does WordPress Offer a Way to Find All of the Categories that Don’t Have Children?
- Taxonomy list. Order by a specific custom post type count
- Action hooks returning old category instead of new category
- Getting WordPress custom taxonomy/category?
- Order Taxonomy Term by date created
- How to get the number of child categories a specific parent category has?
- Get multidimensional array that reflects category hierarchy
- If statement within PHP echo
- Taxonomies for WordPress Media Library [duplicate]
- get_terms orderby numeric
- display taxonomy slug from term ID
- Custom Post Type Archive Page Filtering
- Can you pre-check wordpress categories?
- How to get the id from the custom category?
- How to organize custom categories for filtering and selecting
- Custom sub taxonomy order by
- Is There a Difference Between Taxonomies and Categories?
- How can I edit the ‘Most Used’ tab in the categories meta-box to show another custom taxonomy?
- Getting category URL with hyphens, not spaces
- get_terms function not returning anything
- How to change the order of the subcategory and category in a post?
- How to Link to Most Recent Custom Post of Same Term
- custom page for custom Taxonomy
- Custom page category taxonomy 404
- Filter By Category Dropdown List With Custom Taxonomies
- query_posts by category_name and custom taxonomy
- Getting Category Children
- Is it possible to create an alias/custom taxonomy for a category name?
- I need to exclude from a query a category and a few custom taxonomies
- How to add a date creation field when a custom taxonomy relationship is created?
- WordPress custom taxonomy
- How to load several hierarchical categories from functions.php
- Assign a custom post to a custom taxonomy based on custom field value
- Retrieve Custom Taxonomies with Description and Slug
- Posts not listing out sub category in hierarchy
- Custom Fields Value As Taxonomy
- How to get posts using category slug in ClassiPress?
- Using get_terms() to list terms from one custom taxonomy AND from one specific built-in category
- Combining these queries? (Same taxonomy term + same category as post)
- Link posts together (relative, not grouped)
- Add properties to term object
- get_object_term_cache duplicate terms after update to wordpress 6
- Page category filter in admin dashboard
- Sort categories by custom field in WordPress admin
- How to display custom taxonomy term specific post?
- How to get immediate children of a ‘term’ parent id through ‘get_terms’?
- When creating a new product, auto assign it to all custom taxonomy woocommerce
- How can i echo next and previous custom category from a Taxonomy
- How to load terms of a custom taxonomy of a product in woocommerce cart page
- Using heirarchial tags or Custom taxonomies
- Add subcategories posts to the counts column at the admin’s categories list
- Renaming default category taxonomy?
- Most efficient way to display current post subcategories?
- Categories and Tags Conflict after Woocommerce Installation
- Get category of a taxonomy for a queries object in a loop
- Dynamically creating content on custom URL without getting 404
- How to exclude category and post_tag taxonomy while displaying custom taxonomy?
- New Category – custom taxonomy
- Sorting terms individually for each post
- How to add a new child category via an SQL statement?
- How to create default categories in new installs?
- Why is my post categories not displaying?
- Check if value is a custom taxonomy category name
- finding out the top 5 source ( source is a custom taxonomy ), in a given category
- Modify functions.php to add a term ‘uses-theme’ set to theme name on post save
- Use get variable when rewritten url in wordpress
- Issue on Listing Sub Product Categories In Woocommerce
- Taxonomy page wpml dropdown not working