Add a check wherever you’re displaying the title:
//Anything greater than 0 means the category has parents, 0 means no parent, child category
if($category->category_parent > 0){
echo $category[0]->cat_name;
}
This should help.
Related Posts:
- Get the children of the parent category
- Check if a post is in any child category of a parent category
- How to make child categories recognize parent’s template displays
- Remove “Category Archives: title” at the top of a category page [duplicate]
- Display all posts with same title
- Show children of top level category only
- How can I make wp_list_categories output li with category-slug as class, for its children?
- How to get post category title within the loop?
- Single_cat_title() print the title before text
- Show only first children level of current category?
- Add title, post content, and category like add_post_meta and update_post_meta
- How to remove “Category : …”
- How to remove category titles?
- Hard coded main navigation
- Query Posts Exclude Entire Category
- Category shows only top level child categories
- how to remove the default title of Categories widget
- How to Remove a Title from All Category and Tags Page?
- Give Children Unique ID’s
- About title on a page
- Set category page title in custom theme [closed]
- Show different title on category page
- Check is category parent with ids from the childs – get_term_children
- Check for parent category
- Output Title of Post’s Current Category
- Shop Category Pages missing s
- Include a page’s “category” in its URL
- Category name as page title
- How to create template for children category?
- How to auto update post title and slug with category name when post status is updated
- Need list of child category post titles sorted by child category
- How do you add Author and date Published on Category Pages?
- Children categories not shown in dashboard
- list first post of Child Category on Category page
- How to retrieve posts from parent category, splitting them per children when displayed?
- Weird html output of single_cat_title – is not inside of the html element?
- How to hide my categories pages’ names, and how as well to reduce the space beween my sidebar’s widgets?
- How to create an automatic MultiColoumn MegaMenu with Categories WordPress
- How To Find Out WordPress Category Table in MYSQL?
- How to get this only in small letters (lowercase)? [closed]
- How to totally get rid of Category in my blog?
- Is there a function to cause empty categories not to show in menus?
- Category Specific Archive
- Is there a plugin that will completely remove the category system?
- How to get the number of child categories a specific parent category has?
- Removing category base form links messes up the parent-child behavior
- How to get only the last child of category slug?
- Multisite – create a category in specific site
- How to list only child categories?
- How do you remove display of WooCommerce product category on single product page?
- Show recent posts in menu?
- Cannot add / edit categories to a post anymore
- List archived posts by subcategory
- Convert the default sub-category dashes to bullets or any other characters
- How to check category of of custom post type or not
- Set a them for all subset of category
- How to query post like normal search would do. within search.php page
- WordPress Get Posts from each category equally
- Unwanted Duplicate Product Categories in WooCommerce
- Why custom taxomony not showing when create a post?
- Single.php Category Post Count
- wp_list_categories with show_count, except for specific categories
- How do I include the category next to the title of a post?
- Show the amount of posts in a tag in a specific category has
- Adding a H1 Tag to Post Tags automatically, but hide the tag? (Same for Category)
- How do I add a category to my post_type
- Add posts of a certain category to a page
- Show 10 Sub Categories Per Parent Category Page?
- Conditional category & tag statement
- Post Loop Category first show parent then child
- How to display posts from specific category using get_option function?
- Post not found when filtered by category ID
- How to detect /category and /tag base pages?
- Display all posts from selected category
- Is there any better/faster code than this ? It shows the categories that an author had ever posted in
- How to show only child categories using the_category();
- How to get immediate children of a ‘term’ parent id through ‘get_terms’?
- Hide Some Categories in Post Editor
- in post content shortcode works, but hardcoded in same page template doesn’t?
- Only 10 of 233 categories selectable when adding a new post
- When creating category, it creates automatically tag, or, when creating tag, it creates automatically category in same name
- Should I select only the last child product category?
- List posts from a category and embed them into a page
- How to echo Tags and Categories as plain text
- Get category of a taxonomy for a queries object in a loop
- Make related posts display first in search result
- Display sub categories of a parent product in products – woocommerce [closed]
- Loop within category’s posts
- WordPress edit.php category filter to show only posts from direct category and not posts from it child category
- How can I just show portfolio items from 1 category on portfolio page?
- How to add a new child category via an SQL statement?
- Link categories to last post
- wp_list_categories not working on my live site
- how to ask if in two categorys inside if
- How to show video from wp option value?
- Changing Woocommerce categories programatically
- Add an Exclusive or featured tag line to article titles
- How to list out post category name and description in page
- Print child category slug nicename
- Order Categories by Character Count