You can get the current posts category outside the loop by using the get_the_category function.
http://codex.wordpress.org/Function_Reference/get_the_category
When you have the actual category ( however you got it) you can use get_categories, specifically the ‘child_of’ parameter and pass it the parent cat ID.
http://codex.wordpress.org/Function_Reference/get_categories
Also have a look at wp_list_catagories,
http://codex.wordpress.org/Template_Tags/wp_list_categories#Display_or_Hide_the_List_Heading
where you can do something simple like the following to grab the children.
<?php wp_list_categories('orderby=id&show_count=1&use_desc_for_title=0&child_of=8'); ?>
You would probably do an “if” statement to get the children if they exist and if not just show the category.
Related Posts:
- Get rid of WordPress category, tag and author archives?
- How to add the category ID to admin page
- How to create a widgetized sidebar for every category dynamically?
- Display list of Sub-Categories and the posts they contain, within one main Category
- Changing a function in function.php to a shortcode – for listing categories of only a certain post type
- Only show category to certain user levels without plugin
- List only child categories a post is in, of a specific parent category
- List Categories of the Parent Category of the Current Category
- Exclude a category from the filed under list only on some templates
- Listing all posts from current category on page
- exclude category from WordPress Form function
- wp_list_categories, Add class to all list items with children
- Remove “Parent” Selection When Adding/Editing Categories?
- Display only one result from “get_the_category_list”
- Check is category parent or not from its ID
- Limit function to specific post category
- Use template for posts with a particular category grandparent
- Listing Parent, Child and GrandChild Categories and then the PostTitles on Page Template !
- show posts names and links in the sidebar list as categories child
- How to show in search results posts with a particular tag in a particular category?
- How can I get an tag to wrap each ancestor that gets outputted in this condition?
- How can I list random authors from current post category?
- If category is in parent category?
- How to find the number of Tags a post has?
- Get woocommerce catogry
- If in category to be inside of a function
- wordpress wp_list_categories
- Cannot add / edit categories to a post anymore
- wp_dropdown_categories and custom taxonomy + custom post type
- Get all sub-categories of a parent category
- Rename Default Category (Uncategorized) Via a Function
- Filter Home Page Posts in Buddypress [closed]
- Add icon/badge next to posttitle of specific category
- Getting URL of archive (category) page
- How to show only one category in breadcrumb navigation
- Show Available Taxonomy List with Current Category
- Query posts from category based on a filter most favorited
- Exclude category from
- Display the last post by each category?
- How to allow users to post only in certain category and hide elements from edit page?
- List all categories with featured image from post?
- List categories with custom code
- limit a list of tags to one category [closed]
- Add tag parameter to category.php
- Redirect to another page using contact form 7? [closed]
- Categories list loop – add separator every 3 categories [closed]
- Random Featured Image Based on Category
- query_post order desc
- how to wordpress When I click on the category link, subcategories appear
- add slug beside name in Admin Category Checklists
- Showing custom post type categories in the menu
- Change div background acording to the selected category
- get listed category’s id?
- Exclude category from related post
- Post belonging to many categories
- How to put page numbers with the next/previous on a post/category list?
- Categories will only display links to posts
- List Child Categorie and hide the parent
- Adding category dropdown list to theme options page
- Hide specific category from wp_list_categories
- How to show a list of only categories (exclude subcategories)
- Category list with postcount
- Un-highlight Blog Menu Item when Category Menu Item is Selected
- How to use wp_list_categories with plugin category?
- Redirect depending on category chosen
- How to add icon over specific thumb
- How to load several hierarchical categories from functions.php
- Change Default Content when Creating a Post based on Previous Category Choice
- How to add a custom thumbnail size for a specific category?
- create function to call category name and slug
- Is there any better/faster code than this ? It shows the categories that an author had ever posted in
- Different size video display for category page (smaller) & detail page (larger)
- How to add content above footer in posts from specific category
- Getting the posts list visualised in categories tree
- What is the best way to set the post category (Custom Post Type) automatically based on the one of the tags assigned to the post?
- get category in list of posts // shortcode for custom related posts
- Return all Tags and Categories in Separate List
- get taxonomy list in a page in the wordpress
- Save All Post Permalink From A Specific Category into a .txt file
- AJAX load more posts not using correct category and repeating the same few posts
- How Can Hide Define Category in Post Contents?
- Show only top 3 posts from 3 categories in order on home page
- Code to display category-specific single.php is overriding normal single.php, too
- Loop Through Categories in Custom Field
- Trying to see if page is category or single and displaying title with appropriate heading tag
- Function to list posts from current post’s category fails in WP 3.8
- AZ Directory category
- Search tag within category
- Show only one category in main query, issues on tag page
- Listing category
- List products from current category
- Way to show content of a post, but if exceeds character limit revert to excerpt?
- List posts that are in the same category as the current post title
- list taxonomy based on taxonomy
- How do we display a certain category type on a page while hiding all others?
- Show parent-child relationship for categories in the wordpress admin
- How to get child category list post in one template?
- How to display my categories in a list (to a post, not the sidebar)?
- Moving Blog and Changing URL
- Filters do not work when there are multiple (one works)