Two things!
1) Don’t use query_posts()
! Instead, for situations like this, use the pre_get_posts
action to modify the query.
2) I don’t think you actually want to be using a loop here at all (so neither query_posts()
nor pre_get_posts
or even WP_Query
). Rather, I think you’re looking for wp_list_categories
. In your template, you’d probably do something like this (untested):
<?php
// the taxonomy archive term page's term id
$queried_object = get_queried_object();
$term_id = $queried_object->term_id;
$list_child_terms_args = array(
'taxonomy' => 'YOUR_CUSTOM_TAXONOMY_SLUG_HERE',
'use_desc_for_title' => 0, // best practice: don't use title attributes ever
'child_of' => $term_id // show only child terms of the current page's
);
?>
<ul>
<?php wp_list_categories( $list_child_terms_args ); ?>
</ul>
Related Posts:
- Should I use custom taxonomy or custom post type
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- Filtering a custom post type by custom taxonomy in archive template
- How can I list all the categories under a Custom Post Type (taxonomy)?
- How to build a complex page structure
- Child pages on hierarchical Custom Post Types 404s
- Custom-Taxonomy as categories: Remove “most-used” tab?
- Custom permalinks – post type – hierarchical taxonomy’s
- How to show term-specific post list, without posts associated with child terms?
- Add filter to wp_list_categories and query what type of taxonomy-terms it use?
- Custom edit post column – category not showing
- Getting taxonomy terms used by custom post type
- Taxonomy list. Order by a specific custom post type count
- How to show custom taxonomy in the permalink?
- Custom post type taxonomy template
- Custom/separate categories for custom post type
- Taxonomy structure of Sport site
- get_categories() for only CPT
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- custom taxonomy archive by year
- Custom Posts Hierarchy? (State/City/Restaurant)
- Automatically populate a hierarchical taxonomy from a custom field
- Get categories and descriptions from custom post type
- Custom Taxonomy – Tags Metabox is showing instead of Categories
- Querying Term Posts in Loop
- How to create new category for custom post type?
- Weird problem happening with custom taxonmy when creating/updating posts
- Display custom post type in hierarchical order with get_terms
- Custom Post Types and independent Categories – complex Taxonomy
- Custom Post Type Archive Page Filtering
- How can I auto-assign a CPT post to category in a custom taxonomy when published?
- Conditional Statement custom post type category
- Custom Post Type With Categories
- Hierarchical Custom Post Types in Array
- Categories sorting
- Categories of custom taxonomy don’t show any posts
- Show a Category X’s custom post type on Category X archive page?
- How to create custom url structure based on custom post type rewrite slug, taxonomy and category slug?
- 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
- How to edit this code to get the categories in achieve page?
- Hierarchy and access control for Custom Post Types (CPT)
- Best method to make posts searchable, sortable and filterable – custom field, tag or category?
- Custom while loop for hierarchical display of a taxonomy
- Get the taxonomy of a post hierarchically
- Custom post type / taxonomy rewrite archive page 2 gives 404
- browse by category and tags?
- I am trying to hide a custom post type category to logged in users with Pre_Get_Posts
- Create more category hierarchical depth for custom post type/taxonomy plugin (widget)
- Hierarchial Custom Post Types/Taxonomies
- Hierarchical permalinks for custom post type and taxonomy
- List of Posts and Categories
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- Get parent category id from child category page for custom taxonomy
- How to add current custom taxonomy slug to body class
- How to Display Posts From Category Within a Custom Taxonomy?
- Disable custom taxonomy on admin bar
- Why does my taxonomy have a category style div id?
- The Difference Between Categories and Tags and Taxonomies and Terms
- Custom Post Type Categories URL not displaying posts
- Migrating Hierarchal Taxonomy Categories Between Post Types
- Ideas on how to organize a project [closed]
- get_terms() parent, child and grandchild
- How should I structure complex content hierarchies?
- Custom Post Type Custom Archive Page Not Working
- Displaying One Custom Post Type’s Content On Single Post of Another Custom Post Type
- Custom post types category
- Get terms for a specfic post from multiple taxonomies in custom post type
- Custom post not appearing under custom taxonomy category
- Custom post type category permalinks and archive pages
- how to organize my categories or should I do custom post types for some?
- Advanced archive url structure (category, tag and date)
- Using get_terms() to list terms from one custom taxonomy AND from one specific built-in category
- Can’t Get Parent and Child Categories of Custom Taxonomy to Display
- How to divide Subcategories into pages of parent category wordpress
- Custom front-end form for adding post – Category problem
- How to display custom taxonomy term specific post?
- Show Custom Post Type based on Category on Archive Page
- Custom category taxonomy – archive page not showing up
- Create a Hierarchical List of Custom Taxonomies AND Posts
- Custom post types not displaying per category
- Custom post type category archive URL redirects to home page
- Custom Post Hierarchy and users
- Dropdown switching subcategories portfolio
- Display custom Taxonomies same as listing Categories
- How can I add a “fake” parent into the permalink?
- Organizing The Custom Post Type with Taxonomies / Parent Posts
- Display 2nd category, only once, as sub-heading, in the loop
- taxonomy term names in custom post type permalink structure
- Get a list of categories ids
- Custom taxonomy archive not showing posts of certain child taxonomies
- Category / Custom Post Type permalink issue
- Return Custom Post Type Categories
- Remove slug from Custom Category Permalink + dual-category permalinks
- How can I show second most recent post in sidebar, if most recent post is open in the browser?
- Is it possible for post and custom post type to share a category base slug?
- How to add categories to a custom post type using wp_insert_post($new_post);
- How to develop Knowledge center in WordPress Website