Echo custom taxonomy slug

Here’s the correct syntax for what you’re trying to do, if there’s just the single value for the ‘series’ custom taxonomy slug that you’re trying to retrieve. You were passing the whole array to your echoed string. I made a new variable $series which pulls the first/only value in the $terms_slugs array. And simplified a … Read more

WordPress Term for Custom List

In wordpress they are called Custom Post Types. You can create them for instance in the functions.php. There are many examples in the web how to do that.

Get terms within a custom taxonomy

In wordpress a parent for a term is always referred to the same taxonomy. So as you already understand what you need is create a texonomy in which parent term rapresents a ‘School’ and a child term rapresents a ‘Group.’ Maybe a third-level-term rapresents a ‘Sub-Group’ or something else. Doing so and using the argument … Read more

Get all attachments by custom taxonomy – term

To get all images from the same term you can use WP_Query with the “tax_query” argument: $args = array( ‘post_status’ => ‘inherit’, ‘posts_per_page’ => -1, ‘post_type’ => ‘attachment’, ); $args[‘tax_query’] = array( array( ‘taxonomy’ => ‘YOUR_CUSTOM_TAXONOMY’, ‘terms’ => array( ‘YOUR_CUSTOM_TAXONOMY_TERM’ ), ‘field’ => ‘slug’, ), ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() … Read more

Hide image if taxonomy term is empty

Instead of write manually the html code for your flags, you should create it using php and wordpress functions: $countries = get_terms(‘country’, array(‘hide_empty’ => true) ); $exclude_terms = array(‘featured’); if ( ! empty($countries) && is_array($countries) ) { ?> <img class=”mapAdjust” src=”https://wordpress.stackexchange.com/questions/114245/<?php bloginfo(“template_url’); ?>/img/map-adjust.gif” /> <img class=”map” src=”https://wordpress.stackexchange.com/questions/114245/<?php bloginfo(“template_url’); ?>/img/map.jpg” /> <?php foreach ( $countries as … Read more

Get a count of how many times a term or a category is used in posts

Wp_Query should be able to do this for you. Pass it the appropriate parameters, including a tax_query, and check found_posts. $p = new WP_Query( array( ‘post_type’ => ‘custcpt’, // your CPT ‘tax_query’ => array( array( ‘taxonomy’ => ‘custtax’, // your tax ‘field’ => ‘id’, ‘terms’ => $cat->term_id, // your term ID ) ), ‘ignore_stickie_posts’ => … 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