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
- Exclude a category from WP_Query
- How can I list all the categories under a Custom Post Type (taxonomy)?
- 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
- Child pages on hierarchical Custom Post Types 404s
- Glossary with Custom Post Type
- How to check if last uri segment is a custom post type or taxonomy term?
- Custom-Taxonomy as categories: Remove “most-used” tab?
- Filter get_categories() for taxonomy term in WordPress
- 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
- Custom Taxonomies: Multiple Hierarchical Permailnks For A Single Post + Prev/Next Links
- How to show custom taxonomy in the permalink?
- Custom post type taxonomy template
- Custom/separate categories for custom post type
- Display Posts of a Category in Alphabetical Order (Custom Post Type)
- Taxonomy structure of Sport site
- Hierarchical Custom Post Types or Similar
- Display Custom Category (taxonomy) Name in Custom Post Type
- get_categories() for only CPT
- Display types of posts in edit.php instead of All, Published, Scheduled and Draft
- Show Post Count of a Category
- How to create a permalink structure with custom taxonomies and custom post types like base-name/parent-tax/child-tax/custom-post-type-name
- custom taxonomy archive by year
- Custom Posts Hierarchy? (State/City/Restaurant)
- Custom Post Type with two hierarchical Custom Taxonomies: strategy to generate best permalink structure
- 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
- Combining custom post type and post category
- 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
- Insert HTML inside link in a walker
- Custom Post Types and independent Categories – complex Taxonomy
- Set menu active state for custom posttype and category, given custom taxonomy term
- Display all posts in main category and 1 subcategory
- Custom Post Type Archive Page Filtering
- How can I auto-assign a CPT post to category in a custom taxonomy when published?
- Custom Post Type / Two level deep taxonomy (cat. and subcat.) uri problem (error 404)
- Posts from all the categories are being displayed instead of particular category
- Conditional Statement custom post type category
- Custom Post Type With Categories
- Hierarchical Custom Post Types in Array
- Categories sorting
- Allow user to set custom order to a list of custom taxonomies?
- get_category_parents for custom post type taxonomy
- wp_list_categories() – current-cat class also inside posts?
- Categories of custom taxonomy don’t show any posts
- How to display custom taxonomies with links in filter menu?
- Show a Category X’s custom post type on Category X archive page?
- Cannot add category or custom taxonomy from admin. WordPress site is hosted in Windows 16 server via IIS. No XAMPP or WAMP
- How to create custom url structure based on custom post type rewrite slug, taxonomy and category slug?
- Hide parent categories when clicked, and show it’s childs
- Limit amount of posts made within a 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
- 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?
- How to get custom posts sub category link
- 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 Permalinks with hierarchical Taxonomies
- Create a permalink structure with custom taxonomies and custom post types gives 404
- Custom Post Type Category Link
- Custom Post type category pages template and loop
- WP the_posts() on single-cars.php get category link
- in_category for custom post types
- Get parent category id from child category page for custom taxonomy
- Custom Post type & Taxonomy 404
- How to add current custom taxonomy slug to body class
- List Posts By Custom Taxonomy
- 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
- WP Query filtering by custom category not showing all relevant posts
- How to get the proper category in permalink with custom post type assigned to multiple categories
- Category display using conditions
- List all posts in hierarchy and groupped by each taxonomy