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
- Custom page category taxonomy 404
- How do order product categories – on a parent category page – in Woocommerce?
- set terms to category and subcategory
- Filter By Category Dropdown List With Custom Taxonomies
- How to display taxonomy terms the way they are hierarchical
- query_posts by category_name and custom taxonomy
- Getting Category Children
- Is it possible to create an alias/custom taxonomy for a category name?
- More efficient way to list posts by category [duplicate]
- Same menu for different taxonomies to reach different content
- I need to exclude from a query a category and a few custom taxonomies
- Exclude categories by ID
- How to add a date creation field when a custom taxonomy relationship is created?
- Get terms for a specfic post from multiple taxonomies in custom post type
- Using in ‘category_name’ in ‘$query->set();’?
- How to store category and tags separatly on wordpress?
- WordPress custom taxonomy
- Category link redirect to custom template page instead of index.php?
- How could I write a get_categories_by_year() function?
- 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
- Order taxonomy terms wordpress
- Show single Child Category on Custom Post
- Posts not listing out sub category in hierarchy
- Natural sort / ordering wp_dropdown_categories
- wp_delete_term or wp_delete_category?
- Custom Fields Value As Taxonomy
- Update custom category fields front-end
- 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
- Sort posts alphabetically by category/custom taxonomy, insert divider between different types
- Combining these queries? (Same taxonomy term + same category as post)
- 3.1 post formats and specific categories/custom taxonomies
- Link posts together (relative, not grouped)
- WP-CLI Add category as menu item main-menu
- Add properties to term object
- get_object_term_cache duplicate terms after update to wordpress 6
- How to fix select filter on category
- Migrate the posts of a category to another blog as a custom taxonomy
- List of post categories only associated to another custom taxonomy
- Page category filter in admin dashboard
- Sort categories by custom field in WordPress admin
- How can I order all subcategories alphabetical independent of the parent categories?
- Automatically add custom taxonomy to posts in a category
- How to set the same base url for two different taxonomies?
- How to display custom taxonomy term specific post?
- Taxonomy custom check box meta field not getting saved
- How to get immediate children of a ‘term’ parent id through ‘get_terms’?
- Replace deprecated get_category_children code with get_terms
- How to order taxonomy terms by most recent post?
- Can’t display posts by filtering categories using isotope.js
- When creating a new product, auto assign it to all custom taxonomy woocommerce
- Grab all the posts for particular category
- How to remove parent category from child category url using wordpress rewrite rule?
- Modifying category order
- How can i echo next and previous custom category from a Taxonomy
- Restrict retrieved terms by category?
- List non-empty categories from a custom post type
- How to modify custom category field from front end?
- How to load terms of a custom taxonomy of a product in woocommerce cart page
- Using heirarchial tags or Custom taxonomies
- How to assign Categories and tags inside the TinyMCE Editor for each Image?
- outputting taxonomy hierarchy
- Bulk Change WordPress category Slug
- Add subcategories posts to the counts column at the admin’s categories list
- Why use hierarchical taxonomies instead of many custom taxonomies?
- Renaming default category taxonomy?
- show only terms from parent category
- 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
- get_terms sort order with child categories of varying depth
- Getting a sub category based on a category name
- How to Manage and link certain custom taxonomy?
- Orderby taxonomy term id using get_posts not working
- Getting Post Tags From Certain Categories
- Dynamically creating content on custom URL without getting 404
- Configure query with multiple categories in a custom order?
- How to exclude category and post_tag taxonomy while displaying custom taxonomy?
- New Category – custom taxonomy
- How to add a post with new Taxonomy without assigning to default category?