Check if Current Category has Children

There may or may not be a better way to do this, but here’s how I would do it: $term = get_queried_object(); $children = get_terms( $term->taxonomy, array( ‘parent’ => $term->term_id, ‘hide_empty’ => false ) ); // print_r($children); // uncomment to examine for debugging if($children) { // get_terms will return false if tax does not exist … Read more

Get term name from term ID?

The function get_term_by() would allow you to get the taxonomy term name from the id. $quantityTermObject = get_term_by( ‘id’, absint( $quantityTerms ), ‘quantity_category’ ); $quantityTermName = $quantityTermObject->name;

Is ACF being a honey trap? [closed]

Few months ago @tom-j-nowell (one of the mods here) wrote an article explaining the issues with the abuse of meta queries by many WP plugins: https://tomjn.com/2016/12/05/post-meta-abuse/ Among other things he says there: […] sites have been brought down by this, and it’s the reason a number of popular plugins don’t scale to high traffic […] … Read more

Get term SLUG by term ID

I have bit of trouble understanding your question. Taxonomy (like category) slug or term (like uncategorized) slug? get_term_children() works with terms so I will stick with that. Try this: $term = get_term( $id, $taxonomy ); $slug = $term->slug;

How to only list the child terms of a taxonomy and not their parents?

This should work for you: $taxonomyName = “age”; //This gets top layer terms only. This is done by setting parent to 0. $parent_terms = get_terms( $taxonomyName, array( ‘parent’ => 0, ‘orderby’ => ‘slug’, ‘hide_empty’ => false ) ); echo ‘<ul>’; foreach ( $parent_terms as $pterm ) { //Get the Child terms $terms = get_terms( $taxonomyName, … Read more

get_terms – only top level

Your code is correct, well almost correct. On first view, I must confess, I missed it too. You have two syntax errors in your code. If you look closely, ‘parent ‘ and ‘parent’ is not the same. You should not leave blank spaces between single quotes (‘) and arguments. Also, you don’t need to add … Read more