If you want to list only child categories of the current category, set the child_of
argument to the current category ID.
wp_list_categories(
array(
'child_of' => get_queried_object_id(), // this will be ID of current category in a category archive
'style' => 'none',
'title_li' => ''
)
);
EDIT- To list only child categories per-post of the current category, you’ll need to filter the list of each post’s terms to check that parent
is the current category ID.
$terms = get_the_terms( get_the_ID(), 'category' );
if( $terms && ! is_wp_error( $terms ) ){
echo '<ul>';
foreach( $terms as $term ) {
if( get_queried_object_id() == $term->parent ){
echo '<li><a href="' . get_term_link( $term ) . '">' . $term->name . '</a></li>';
}
}
echo '</ul>';
}
Related Posts:
- Can I set a default featured image for a category?
- Could not insert term into the database
- What’s the URL for a category archive?
- Weird behaviour when adding terms/term_taxonomies programmatically
- How can I get category ID by category name?
- How would I increase the Author Role to be able to add a new category?
- Randomise results from a category page?
- Multiple level category drop-down
- Adding Custom User Profile data based upon Categories
- Only show category to certain user levels without plugin
- How to split the categories of subcategories with thumbnails
- WordPress MU 2.9.2 to 3.0.5 changes to category.php
- Keep active class in post page
- Add custom category name as data-filter to switch between these categories
- Categories lose hierarchy order once assigned to post
- What’s the difference between “parent” and “category_parent” in a WP_Term object?
- Catchable fatal error: Object of class WP_Term could not be converted to string
- Update taxonomy value of post type in query
- Hide tag and category boxes from the post editor
- Add multiple=”multiple” attribute to categories dropdown
- Allow dot in wordpress permalinks (only for categories)
- How to know if it’s a child taxonomy?
- Collapse subcategories in post edit screen
- Categories: A Greenhorn Question on Strategy (Not Code)
- Using a portfolio_category slug in wordpress URL
- Exclude category from Tag Template
- How to provide value for ‘selected’ on wp_dropdown_categories() for ‘multiple’ options
- Need Category RSS Feed that shows all posts
- How to display post images in category view?
- Nav menu category links not showing
- Making a tourism information website [closed]
- How would I go about adding custom header images per category?
- Exclude a category from the_category in the single post page
- Post publish directly in all categories except one need pending review
- Display category posts before others category custom query [closed]
- Get Prevous/Next Post Specific Category Without Excludes
- Pagination is not working properly in Product Category/Tag pages
- add_rewrite_endpoint returns 404 on archives
- Multiple category archive page
- How to display post type and category links in foreach WordPress code
- Sub Categories Keep Redirecting to Pages With Same Slugs
- Category template to show different categories based on parent
- Customize category page for different custom taxonomies
- Get posts under a category with SQL
- Inside a loop, how to change CSS class based on category name?
- Conditional IF current cat is the smallest/last/end child cat THEN
- Randomly load categories with latest post
- Is it possible to remove from default category widget?
- How to create a custom meta box field in category? [duplicate]
- How to show 1-5 of X Total Results
- Combine “category search order” with “don’t display child posts”
- SQL query to return categories and category parents
- How to Remove a Title from All Category and Tags Page?
- category__not_in and id values from variable
- WordPress Show Parent Category Description for Sub-categories
- If x comments in a post move post to category y
- why get_the_post_thumbnail( the_ID()) echos extra post id
- Adding additional content on post depending on post categories
- Root category template?
- How to not display subcategories in Recent Posts widget area?
- Getting the Most Recent Posts from Multiple Categories
- wp_list_categories not excluing multiple ids
- Add Date & Author Meta to Category Archive Page
- A dropdown with checklist
- Custom meta boxes ID prefix showing on first category but not others
- Exclude category from foreach loop
- How to store category and tags separatly on wordpress?
- Show Secondary Sidebar on Category pages (archive)
- Get categories of queried posts
- wp_delete_term or wp_delete_category?
- Get post content intro text on category.php?
- Conditional category query breaking?
- Different header for each category
- Unable to browser posts in categories
- 3.1 post formats and specific categories/custom taxonomies
- sidebar troubles, taxonomy trouble
- Code for Category, Tags, Archive URLs
- wp_get_post_categories not work currently on loop.php
- Duplicate new categories across multisite network
- Inline If statement to echo CSS [closed]
- Get category base permalink
- Template category.php with page (no posts)
- How to create Child Category page from scratch at wordpress?
- WooCommerce showing active product categories on single product page
- how to exclude specific category types (uncategorized) from blog page?
- How to set featured image as background for a specific category?
- Confused about category.php template – not working
- Limit Category/Tag Dropdown To blog_id in Multisite Install With Global Categories/Tags
- Adding relevant categories to related post
- Code to display category-specific single.php is overriding normal single.php, too
- How to assign image on specified category and not show the image on other categories
- How can I add a Categories page link to a menu? [closed]
- Media Library filter returns undefined function get_current_screen
- Way to show content of a post, but if exceeds character limit revert to excerpt?
- get IDs from links categories
- get posts from 2 categories. (2 posts)
- Display all subcategories for a product category in woocommerce
- Converting Categories (with ACF fields) to custom taxonomies
- Why does my WordPress index has a category?
- Replace category titles inside RSS feed