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
- Filtering a custom post type by custom taxonomy in archive template
- Exclude a category from WP_Query
- How to build a complex page structure
- How to filter custom post types by custom category taxonomy
- Is there a way to use regular categories with custom post types?
- How to list all categories and tags in a page?
- remove support for ‘Categories’ for a custom post type
- Filter get_categories() for taxonomy term in WordPress
- List all posts in Custom Post Type but group dynamically by Custom Taxonomies
- How to show related posts by category or custom post type?
- How to display the rest of categories on Portfolio filterable
- Custom/separate categories for custom post type
- Query Custom Post by Category
- ‘category__and’ for custom taxonomy?
- Display Custom Category (taxonomy) Name in Custom Post Type
- Separate Posts and Custom Post Type in Custom Taxonomy archive template
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- Show Post Count of a Category
- Get categories and descriptions from custom post type
- Combining custom post type and post category
- Insert HTML inside link in a walker
- Normal pages as children of my Custom Post Type
- Only show posts from a certain category?
- Set menu active state for custom posttype and category, given custom taxonomy term
- Display all posts in main category and 1 subcategory
- get_attached_media() on author page not working
- get_category_parents for custom post type taxonomy
- Custom loop with multiple taxonomy queries
- 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
- 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
- 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?
- Display Custom Taxonomy Alphabetically
- How to get custom posts sub category link
- Display related custom taxonomy posts in sidebar
- get_the_title() is returning results from previous loop
- WP the_posts() on single-cars.php get category link
- Main query not querying any posts in custom taxonomy template
- get_category_link() for custom post type does not include custom slug rewrite?
- 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
- category list with cutom post count
- Include custom post type custom taxonomies in Categories widget
- Custom post type categories gives 404 error
- Use post in multiple places on a page with multiple posts
- List all Custom Post Type posts excluding certain Taxnomy term
- Custom Post Type Custom Archive Page Not Working
- Looping through custom taxonomy and display custom post types (Custom Post Type UI)
- Can’t pull posts of a Custom Post Type based on the custom taxonomy of the CPT
- Create a custom taxonomy template that loops through child categories in term order?
- Retrieve Custom Taxonomies with Description and Slug
- Custom post type category permalinks and archive pages
- Loop and add Specific Categories and Products Images
- Custom post type specific category box
- Custom Taxonomy Taxonomies of Same Name point to first created URL
- Multiple custom post type queries causing wrong post types to be grabbed in taxonomy + single templates?
- Can’t Get Parent and Child Categories of Custom Taxonomy to Display
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Custom post type paging return home page
- How to set “section categories”?
- Create custom post type categories
- Custom WordPress theme not displaying posts from category
- Combine multiple separate lists into one
- Set a Default CPT taxonomy by taxonomy id
- Multiple Custom Post Type in Taxonomy Archive Causing White Screen
- Adding a Section for Visitors
- Why is my loop not populating the page with my custom taxonomy terms from my custom post type?
- Show parent category and subcategory once in while loop
- List all posts associated under custom taxonomy
- Loop to display parent categories in custom taxonomy
- Custom taxonomy template for custom fields loop [closed]
- How to show terms used only for particular custom post type. Filter creation perpose
- Show posts for current taxonomy
- Custom post type with custom taxonomy permalinks
- Dropdown switching subcategories portfolio
- Custom Post Type + Category archive
- 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
- Trying to create hierarchy between 3-4 custom post types
- Customize category URL
- Category / Custom Post Type permalink issue
- Categories and page filtering with pre_get_posts
- Loop through multiple custom taxonomy terms and display posts for a custom post type
- display custom post type from register taxonomy
- display all posts in current category
- Get all active posts that are tied to a custom taxonomy for a custom post type
- How to add categories to a custom post type using wp_insert_post($new_post);