Since this is for a taxonomy archive, you can just use get_queried_object()
and the parent
and depth
argument in wp_list_categories()
:
$term = get_queried_object();
$list = wp_list_categories( array(
'orderby' => 'name',
'taxonomy' => $term->taxonomy,
'parent' => $term->term_id,
'title_li' => '',
'depth' => 1,
'echo' => false,
));
if ( $list ) {
echo "<ul>$list</ul>";
} else {
// Nothing, do something else!
}
Note that wp_list_categories()
does not output/return a containing <ul />
, so you need to do so yourself (as demonstrated).
Related Posts:
- Show a Category X’s custom post type on Category X archive page?
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Custom post types not displaying per category
- WordPress Genesis custom taxonomy archive shows 3 repeats of each post
- Display all posts in main category and 1 subcategory
- Am unable to reset a query properly
- Custom Post Type Archive Page Filtering
- get_attached_media() on author page not working
- How can I auto-assign a CPT post to category in a custom taxonomy when published?
- Posts from all the categories are being displayed instead of particular category
- Get next and previous 3 posts in a term in single post page
- Conditional Statement custom post type category
- Custom Post Type With Categories
- Loop custom taxonomy to get lists of cutom post types?
- Categories sorting
- Allow user to set custom order to a list of custom taxonomies?
- get_category_parents for custom post type taxonomy
- Custom loop with multiple taxonomy queries
- wp_list_categories() – current-cat class also inside posts?
- Custom post type multiple loop by taxonomy term
- Categories of custom taxonomy don’t show any posts
- How to display custom taxonomies with links in filter menu?
- List custom taxonomy specific to one custom post type
- Display all taxonomy terms, add class if term applies to current post
- Return the latest post from a custom Taxonomy and Post Type
- Cannot add category or custom taxonomy from admin. WordPress site is hosted in Windows 16 server via IIS. No XAMPP or WAMP
- Displaying CPT and custom taxonomy side by side in Bootstrap 4 component
- Hide parent categories when clicked, and show it’s childs
- Limit amount of posts made within a custom taxonomy
- Group CPT posts by custom taxonomy
- Filter CPT posts by one or more categories
- Getting categories of posts under a custom taxonomy
- Can’t remove front from permalinks for custom taxonomy category page
- Custom post type, organized by categories
- What’s the WP way to load remaining custom posts?
- WP Query with categories only shows one post and ignores the category
- How to edit this code to get the categories in achieve page?
- Display Custom Taxonomy Alphabetically
- Full Custom Post Type List Organised by two Taxonomies
- Hierarchy and access control for Custom Post Types (CPT)
- Best method to make posts searchable, sortable and filterable – custom field, tag or category?
- How to get custom posts sub category link
- browse by category and tags?
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- List of Posts and Categories
- Listing all term items alphabetically / sorting loop
- Display related custom taxonomy posts in sidebar
- Only show posts with date of today or in the future (i.e don’t show past posts)?
- Three Most Recent Posts, One Per Term
- get_the_title() is returning results from previous loop
- WP the_posts() on single-cars.php get category link
- Tag page only display 10 posts
- in_category for custom post types
- Get parent category id from child category page for custom taxonomy
- Main query not querying any posts in custom taxonomy template
- How to add current custom taxonomy slug to body class
- List Posts By Custom Taxonomy
- get_category_link() for custom post type does not include custom slug rewrite?
- How to Display Posts From Category Within a Custom Taxonomy?
- Control content before and after custom post type loop
- Disable custom taxonomy on admin bar
- Why does my taxonomy have a category style div id?
- Targeting categories in custom fields
- looping though custom post types and only return results in a given taxonomy
- Listing all slugs?
- Dynamically insert code to custom post type loop
- category list with cutom post count
- The Difference Between Categories and Tags and Taxonomies and Terms
- Include custom post type custom taxonomies in Categories widget
- Pull in taxonomy field of custom post type in new query
- Custom Post Type Categories URL not displaying posts
- display posts of custom post type with custom taxonomy
- Custom Post Type not showing in main loop
- My custom taxonomy is only displaying 1 of 3 terms
- Custom Post Type and Taxonomy Loop Output Is Wrong
- Custom post type categories gives 404 error
- Get child categories of custom taxonomy category?
- Organizing The Custom Post Type with Taxonomies / Parent Posts
- Loop with Custom Post Type and Taxonomies
- Display 2nd category, only once, as sub-heading, in the loop
- Loop multiple taxonomy in custom post
- How to query all custom posts of a certain type and checking what category they have
- Post Editor: display categories from current post type taxonomy only?
- Post data in separate divs with incrementing class using WP_Query
- WordPress Custom Post Type and sort by Tags
- Get a list of categories ids
- Display posts from category in page
- Trying to create hierarchy between 3-4 custom post types
- Customize category URL
- Order by custom field attribute
- Display Custom Taxonomy of custom post type
- Category / Custom Post Type permalink issue
- Sorting custom post types by taxonomy (So close)
- Looping taxonomy in taxonomy?
- Display a custom post type list by taxonomy term
- Listing custom post type items from a couple of custom taxonomies
- Categories and page filtering with pre_get_posts
- Loop through multiple custom taxonomy terms and display posts for a custom post type
- Return Custom Post Type Categories