Get total number of comments from posts in a specific custom taxonomy

You’ll need to loop through your posts, use get_comments_number() to get the number of comments for each post, and then accumulate the total number of comments in a separate variable. e.g.: <?php $features_comment_count = 0; if ( have_posts() ) : while ( have_posts() ) : the_post(); $features_comment_count += get_comments_number(); endwhile; endif; ?> (I’ll assume that … Read more

Taxonomy slug by term ID

For a menu object $item: $item->object stores the object the menu item refers to, e.g. ‘post’, ‘page’, ‘my-cpt’, or ‘my-taxonomy’ (the post type name, or the taxonomy name) $item->type stores what ‘type’ of object is it, either: ‘post_type’ or ‘taxonomy’. For custom links, these are both custom

A better Media LIbrary Experience

Yes, the media library is long overdue an overhaul, and it seems there are some guys working on it right now. With any luck some changes will make it in to the next release. Take a look here at some of the slides and the many commments and feedback: http://make.wordpress.org/ui/2012/07/30/media-wireframes/

wp_insert_term is adding a term that has no name

As noted in the OP’s comments, some non-ASCII characters may not be supported in term names under certain conditions. To replace all suspect characters with an underscore, use the following code: $categoryname = preg_replace(‘/[^a-z0-9]/i’, ‘_’, strtolower($categoryname)); wp_insert_term($categoryname, “department”); To replace all suspect characters with a dash, use the following code: $categoryname = preg_replace(‘/[^a-z0-9]/i’, ‘-‘, strtolower($categoryname)); … Read more

Return only the custom sub-term for custom post type, do not echo term-parent

Here’s more of a complete guide based on the $wp_query object: The Taxonomy First you might want to know in which taxonomy you are, what its name is and retrieve all its available data from the object. // Taxonomy name $taxonomy = get_query_var( ‘taxonomy’ ); // Taxonomy object get_taxonomy( $taxonomy ); // Taxonomy name get_taxonomy( … Read more

Display child taxonomy until the last child

Got some ideas for your requirement. Check below code… $parent=get_queried_object()->term_id; $child = get_categories(‘child_of=”.$parent. “&hide_empty=0&echo=0&taxonomy=custom_taxonomy’); if(count($child)>0){ $i=0; foreach ( $child as $row ) { $i++; echo ‘<li><a href=”‘.get_term_link($row,$row->taxonomy).'”>’.$row->name.'</a></li>’; if(count($child)==$i){ $args=array( ‘post_type’ => ‘custom_post’,’order’ => ‘DESC’, ‘posts_per_page’=>1,’tax_query’ => array( array(‘taxonomy’ => ‘custom_taxonomy’,’terms’ =>$row->term_id, ‘field’ => ‘id’ )) ); $second_query = new WP_Query( $args ); if ($second_query->have_posts()) : … Read more