If you know the parent category name, then you could just do an if inside the foreach
Demo code
<?php
foreach((get_the_category()) as $category) {
if($category->cat_name!="parent category name") {
echo '<a class="tag-cat ' . $category->slug . '" href="' . get_category_link($category->cat_ID) . '">' . $category->cat_name . '</a>';
}
} ?>
?>
Related Posts:
- WordPress Multisite – global categories
- Get posts from sites in Multisite?
- Retrieve Product category ‘NAME’ by product category ID – WooCommerce?
- Can’t custom taxonomies have same terms (slugs) as categories?
- Using wp_category_checklist in a widget
- How to show subcategories in categories else show posts
- How to remove the parentheses from the category widget
- Filter front page posts by category
- How to get the url to tag & category base set by the user?
- Exclude one category from get_the_term_list
- WordPress remove separator from last item in wp_list_categories
- Need help adding custom field to category
- How to Include the Parent and Child Category in the Permalink if the Post is Added to Both
- How to display a list of categories
- Root level category, tag, author and archive pages to work
- Number of posts in page – set per category and exclude sidebar
- Create single.php for specific category by category id
- is_category in pre_get_posts results in php notices
- Display one latest post from multiple categories
- Archive pagination causing 404 with permalinks structure
- Use get_term_children to get the sub category of a parent category for the current post
- How to make all posts in a category “unsticky”?
- Get a list of Terms for a specific category
- Get a variable from object in array [closed]
- How to stop wordpress from showing the selected category on top of others in the category selection?
- Remove Archive Headline and Archive Intro Text fields on category and tag archive pages in WordPress Admin with Genesis framework
- advanced custom field Show field in special categry page [closed]
- Exclude Child Categories Using wp_list_categories
- a-z list, categories and sub categories in loop
- Category slug $_SERVER[‘REQUEST_URI’];
- wp_dropdown_categories and custom taxonomy + custom post type
- How do I get a list of all categories that a given user has written blog posts for?
- Linking products to categories
- How to remove “Category : …”
- Add “page-a” slug to category link if user visit category link from “page-a”
- create a page which displays a list of categories title+ short description?
- How to call custom category field data in theme?
- Query Posts Exclude Entire Category
- One Specific Category To Permalink
- Hide woocommerce category name from specific pages
- select parent category first then child
- WordPress category widget only show categories with children
- How to exclude children categories of parent category
- Woocommerce custom category page with pagination [closed]
- Menus don’t work after 4.4 [closed]
- Custom post and category template pagination problem
- Multiple category selection in post, shows less important category in breadcrumb
- I want to display the all the posts that are inside a certain subcategory
- How to list all categories in three divs dynamically based on the quatity of categories?
- Grouping categories by genre
- how to “not” display new posts with a specific category on the main page?
- Category template with pagination returns 404 on next pages
- Display custom taxonomy attached to the post on post single page
- Limit categories and it’s subcategories for specific group of users
- show all WordPress categories in a page
- Ive got a term (get_term_by) but now I want to filter it by a category it is in?
- Get and show all of the available categories
- how to remove the default title of Categories widget
- Problems with my conditionals in single.php by category
- Recent post by custom select query
- WP_safe_redirect not working
- Do not show sub categories in the loop on archive-product.php
- Having a template per category? Bad for server overhead?
- Add custom code at start and end of all posts in a category
- Group search results by category
- Anchor tag generates blank href attribute using echo esc_url( )
- WordPress monthly archive category specific
- Add multiple orderby with pre get posts
- Is custom menu name and category name linked in wordpress?
- Exclude the category of the current post
- Output Title of Post’s Current Category
- Related Post by category, but not current category child
- Displaying posts of given category
- Location Based Permalink
- get list of category from a specific post with get_term()
- Return all Tags and Categories in Separate List
- Featured Category or Special Category in WordPress
- How to show given products only using product id array from specific category page in woocommerce
- Ordering terms whilst in loop
- List non-empty categories from a custom post type
- Pass WordPress variable to the next page
- Creating a linkable category list with post count
- How can I list all slugs categories?
- Displaying only selected categories
- No results found for second level category
- get_the_category vs wp_get_post_categories
- Categories in media library
- WordPress Shop and restricting products and categories for some users/groups
- Pass list of categories to JS
- WP url to get rss with full text of post
- WP_query exclude a category unless it has more than one catagory
- Paginating a list of all posts collected by category titles
- Customize category query in widget
- Page permalink rewrite
- Narrow Down a Shop Page Results Based on a Product Tag in WooCommerce
- How to control order when displaying child categories
- Broken category styling
- Trying to WP_Query a category
- Woocommerce Force the category choice before creating new product? [duplicate]
- Custom EndPoint not working when strip child category in URL