How to update incorrect post count in taxonomy?

It only took 3.5-years for someone to be put into the position of @robert-andrews to chase down the post count problem. While having the same problem (and misinterpretation), I ran across your post yesterday in my search for answers. Nothing good really turned up. So, I was forced to trace the code and take the … Read more

Get current term’s ID

Here is a function I use to list subterms: /** * Lists all subentries of a taxonomy. * * @return void */ function ttt_get_subterms( $args = array () ) { if ( ! isset ( get_queried_object()->taxonomy ) ) { return; } $options = array ( ‘child_of’ => get_queried_object_id() , ‘echo’ => 0 , ‘taxonomy’ => … Read more

Get main parent categories for a product

just to offer a alternative solution that might help somebody: code function wc_origin_trail_ancestor( $link = false, $trail = false ) { if (is_product_category()) { global $wp_query; $q_obj = $wp_query->get_queried_object(); $cat_id = $q_obj->term_id; $descendant = get_term_by(“id”, $cat_id, “product_cat”); $descendant_id = $descendant->term_id; $ancestors = get_ancestors($cat_id, ‘product_cat’); $ancestors = array_reverse($ancestors); $origin_ancestor = get_term_by(“id”, $ancestors[0], “product_cat”); $origin_ancestor_id = $origin_ancestor->term_id; … Read more

wp_get_object_terms – How can I order the resulting array by hierarchy?

Just a rough sketch to get your idea: countries (hierarchical taxonomy) France (country – sub taxonomy) Champagne (state – sub sub taxonomy) Le Mans (city – term) Angers (city – term) Nantes (city – term) And you want to order: $query_results = query( ‘country’ => ‘france’, ‘orderby’ => ‘state city’, ‘order’ => ‘ASC’ ); Did … Read more

Glossary with Custom Post Type

$index = 0; $terms = get_terms(‘marke’); $range = array_merge(range(0, 9), range(‘A’, ‘Z’)); echo ‘<ul>’; foreach ($terms as $term) { if(ord($range[$index]) <= ord(strtoupper(substr($term->name, 0, 1)))) { while($range[$index] != strtoupper(substr($term->name, 0, 1))) { echo ‘<li>’. $range[$index] . ‘</li>’; $index++; } $index = strtoupper(substr($term->name, 0, 1)); echo “<li><a href=””.get_term_link($term).”” />{$range[$index]}</a></li>”; $index++; } }

Retrieving custom taxonomy in order, but excluding specific tax IDs

Alas no answers or comments! 😛 Not to worry, a colleague helped me out here and here is the above code working with an $exclude function terms_by_order($taxonomy, $exclude) { global $post; $terms = get_the_terms($post->ID, $taxonomy); // check input if ( empty($terms) || is_wp_error($terms) || !is_array($terms) ) return; // exclude foreach ($terms as $key=>$term) { if … Read more