Handling Multi-level custom taxonomy hierarchy

You’ll probably have to run a cycle using get_terms() paired with the ‘parent’ attribute. $args = array( ‘parent’ => 0 ); $parents = get_terms( array( ‘custom-tax’ ), $args ); foreach ( $parents as $parent ) { echo $parent->name; $args[‘parent’] = $parent->term_id; if ( $children = get_terms( array( ‘custom-tax’ ), $args ) ) { foreach ( … Read more

What is the action hook that deletes a taxonomy term from the backend? And how to retireve the term id before deleting it?

Actually, you can use multiple actions, at least this is what at the end of the wp_delete_term function, which runs when you click Delete on a taxonomy term: do_action( ‘delete_term_taxonomy’, $tt_id ); do_action( ‘deleted_term_taxonomy’, $tt_id ); do_action( ‘delete_term’, $term, $tt_id, $taxonomy, $deleted_term ); do_action( “delete_$taxonomy”, $term, $tt_id, $deleted_term ); The last one my be the … Read more

Get object for a few selected taxonomies

I am not aware of a function to get only specific term objects for a post type but it is not hard to filter out the ones you want. For example: $taxonomies = get_object_taxonomies( ‘post’, ‘objects’ ); $taxonomies = array_intersect_key($taxonomies,array_flip(array(‘category’,’post_tag’))); var_dump($taxonomies); But since you know the taxonomies you want, you could also just use get_taxonomy( … Read more

Displaying Custom Taxonomy without a hyperlink

Use get_the_terms instead of the_terms. http://codex.wordpress.org/Function_Reference/get_the_terms Something like this should do the trick: $terms = get_the_terms( get_the_ID(), ‘ehp_volumes’ ); $term_count = count( $terms ); if ( $term_count > 0 && ! wp_error( $terms ) ) { $terms = array_values( $terms ); // reset keys for easier looping. by default the key matches the term id … Read more

How to customize taxonomy archive template files for subterms?

Strictly speaking, according to the Template Hierarchy, you cannot. Unfortunately taxonomy-$taxonomy-$term-$subterm.php is not provided for in default, so this file structure will not work. The best you can do here is taxonomy-$taxonomy-$term.php So for Thailand you will name your template as follows taxonomy-location-Thailand.php EDIT Just to add to my answer, the file structure that you … Read more