Ordering taxonomy output in this function

get_ancestors() returns an array with the parent first, then the grandparent, etc. What you need to do change get_ancestors() to array_reverse( get_ancestors() ), so that you have the level of the parents descends, instead of ascending.

How do I print a term list but alter the link text?

<?php $terms = get_terms( $taxonomies, $args ); $term_name_array = array(); foreach($terms as $term){ $term_name_explode = explode(“-“,$term->term_name); $myterm_name=””; for($i=0;$i<count($term_name_explode)-2;$i++){ $myterm_name.=” “.$term_name_explode[$i]; } $myterm_name = ltrim($myterm_name); if(in_array($myterm_name,$term_name_array)) continue; $term_name_array[] = $myterm_name; ?> <li><a href=”https://wordpress.stackexchange.com/questions/48983/<?php echo get_term_link($term->term_id)?>”><?php echo $myterm_name;?></a></li> <? } ?>

wp_insert_term does not insert description. [closed]

I was having the same problem the other day, due to a completely different typo 😉 $args = array( ‘description’ =>”My Desc”, ‘slug’ => “My Slug”, ‘parent’ => 0 ); $result = wp_insert_term(“Term1”, “category”, $args); Note the corrected ‘description’ element in the $args array.

How to write sql query to get the posts from a custom taxonomy term name

@Sisir linked you to the appropriate place, if you had read the question/answer and the linked Codex documentation you’d have seen that you could do something like the following: $args = array( ‘post_type’ => ‘dealers’ ‘tax_query’ => array( array( ‘taxonomy’ => ‘state’, ‘field’ => ‘slug’, ‘terms’ => array(‘bob’,’angela’,’john’,’smith’,’jan’,’doe’,’etc…’) ) ) ); $query = new WP_Query( … Read more

Query posts using custom taxonomy and selected terms

You’re using a deprecated method of querying by taxonomy. Read the Codex and use tax_query: $args=array( ‘post_type’ => ‘book’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => -1, ‘caller_get_posts’=> 1, ‘tax_query’ => array( array( ‘taxonomy’ => ‘facts’, ‘field’ => ‘slug’, ‘terms’ => ‘information’ ) ) ); FYI, caller_get_posts is also deprecated.

Get Categories Where Taxonomy Equals ‘n’

get_categories() only lists categories, so you shouldn’t be seeing any terms from the custom taxonomy. What you want to use is get_terms() which takes a taxonomy as an argument. As you can read about in this answer, get_terms() is actually used by get_categories(), it just prefills the “taxonomy” argument with “category.” If you swap in … Read more