You can use PHP’s array_filter
to process the results of a taxonomy query function that returns its results, and then display them. Something like:
# This returns the whole taxonomy...
$whole_tax = get_terms('customtax', array('hide_empty' => 0));
$second_level = array_filter($whole_tax, function ($t) {
# This term has a parent, but its parent does not.
return $t->parent != 0 && get_term($t->parent, 'customtax')->parent == 0;
});
At this point you can render $second_level
to output in whatever format you want.
NB. If this is often used on a busy side should avoid all those extra get_term
calls by reading from the $whole_tax
array assuming the documentation’s statement that get_term
always hits the database when passed an id.
Related Posts:
- Change order of Custom Taxonomy List
- How to get current term in my custom taxonomy in WordPress?
- Get only the first term by taxonomy
- get_terms() returns an empty array
- Custom Taxonomy Only Showing Top Level Terms in Admin?
- Dropdown: Display terms from B only if has relationship with a term A selected
- Get current term’s ID
- Is it possible to get a Previous/Next Taxonomy term archive URL?
- Showing posts by collection of specific terms and texonomy
- WP_insert_term how to insert multiple values as taxonomny term?
- term_link() filter or rewrite and howto?
- How to set hierarchical terms to a post using wp_set_object_terms
- Custom taxonomy term as class?
- How to edit/remove a term that’s in multiple taxonomies?
- Custom taxonomy term in WooCommerce product permalink
- how to create a proper query for getting a list of users with taxonomy related meta key
- Allow only 1 instance of each term in each custom taxonomy
- Generic taxonomy-term template page
- Outputting an array of term meta values in a custom WooCommerce tab?
- Get terms from posts submitted within a certain time
- Display Terms for all posts in Current Archive or Query
- Get direct children of custom taxonomy
- get_terms: determine if taxonomy term has children
- Display post taxonomies tree
- List subcategory on taxonomy term page
- Operations with custom fields values in a loop
- get_term_children returns WP_Error for custom taxonomy
- display taxonomy slug from term ID
- Displaying terms by first letter
- How to use get_the_terms() to display multiple terms?
- List posts of term on term’s admin edit page
- Get custom category image from menu
- Same taxonomy for different object types
- Can I use a Custom Meta Value inside of ‘get_the_terms’?
- Display only child terms of a specific parent term of a custom taxonomy, for each custom post
- Same term from custom taxonomy in two different custom post types?
- Can’t set custom taxonomy terms via custom form
- Some custom taxonomy child terms not showing in admin. Caching problem?
- get_terms not returning any custom taxonomies
- How do I return all terms from multiple taxonomies?
- Order get_terms() by hierarchy
- What does ‘category__in’ mean in queries?
- Returning One custom taxonomy term name
- Displaying Custom Taxonomy without a hyperlink
- Get all terms, including unchecked, or get the terms outside loop
- get_term_link not working
- How to write sql query to get the posts from a custom taxonomy term name
- Get only immediate children (and not grandchildren) of a hierarchical custom taxonomy term
- How to support fifteen thousand terms in WordPress?
- How to group all terms children’s in custom taxonomy?
- Display Posts by Custom Taxonomy Chosen Terms
- Show template part if part of term
- How to display a custom taxonomy without a link?
- Build filter for post-type + multi taxonomies + multi terms
- How do I get term data associated with the current post, where the result is not wrapped in HTML?
- Hide terms if they aren’t the same as the current term
- Corrupted nav-menu?
- The best way to display taxonomies
- Dynamically set taxonomy term and show admin notice on post save
- List Top 5 taxonomy terms based on number of post
- How to show post list based on taxonomy term?
- Can you hide empty terms using get_term_children?
- get_term_by works but get_terms doesn’t?
- Display empty custom taxonomies differently than with one with posts
- Double slash in the_terms URL
- How to call a custom taxonomy term name inside a function?
- How to add custom taxonomy terms to posts in bulk
- How to list Custom Taxonomy
- List terms of custom taxonomy if matches other taxonomy
- How to output taxonomy term (incl. link to archive) on author.php?
- why the archive of custom taxonomy term shows nothing?
- Display Child Categories of Current Post ID
- Include get_term_link inside search
- Set two terms for a post when they differ only by an accent
- How can I show links for custom posts group by taxonomy current term and sub-term?
- How to use custom slug and custom templates for custom taxonomy?
- How to list custom taxonomy terms alphabetically by last word
- Infinite Scroll appending Next Product Category Term pages
- Listing Cities A custom taxonmy by selection order
- Add A CSS Class To A Menu Item When A Custom Taxonomy Term is Present On Single Post
- Count tags for current post and save into custom meta field (and update it on post edit)
- Add term to taxonomy programatically
- setting a custom post type taxonomy term by code
- How do I check to see if a specific child term has shared posts with another set of child terms within the same taxonomy?
- Output slugs to use as class names for every taxonomy a post is attached to
- set_object_terms for custom taxonomy in custom post type – not working
- Group & Sort Taxonomy terms by letter – Is there a better way?
- Orderby taxonomy term id using get_posts not working
- Permalink Rewrite to include Custom Taxonomy Term
- Trying to Display Number of Posts in Term
- Order posts with custom taxonomy array
- Determine if Term has Grandparent/Great-Grandparent
- Exclude 2 in 3 terms of A Taxonomy from all Archives
- add_query_arg to look up page title
- Altering term_id and name via $wpdb class
- How can I get parent term from a child term
- Create heirachy of post terms from array & assign post to terms
- get_terms() – unexpected ‘=>’ (T_DOUBLE_ARROW) error
- How to delete unused terms?
- Foreach for get_the_terms for hierarchical taxonomy don’t repeat Top Level Terms if contains multiple Second Level Terms