Bien, no sé si esto estará del todo OK, pero está funcionando... así que por el memento me sirve
Código:
function my_custom_get_terms( $my_tax, $my_category ){
global $wpdb;
global $pagename;
$query = "SELECT Count(wp_posts.ID) AS my_term_count, wp_term_taxonomy.term_taxonomy_id, wp_term_taxonomy.taxonomy, wp_terms.name, wp_terms.term_id, wp_terms.slug AS term_slug, wp_terms.term_group, wp_terms_1.slug
FROM (((((wp_term_relationships INNER JOIN wp_term_taxonomy ON wp_term_relationships.term_taxonomy_id = wp_term_taxonomy.term_taxonomy_id) INNER JOIN wp_terms ON wp_term_taxonomy.term_id = wp_terms.term_id) INNER JOIN wp_posts ON wp_term_relationships.object_id = wp_posts.ID) INNER JOIN wp_term_relationships AS wp_term_relationships_1 ON wp_posts.ID = wp_term_relationships_1.object_id) INNER JOIN wp_term_taxonomy AS wp_term_taxonomy_1 ON wp_term_relationships_1.term_taxonomy_id = wp_term_taxonomy_1.term_taxonomy_id) INNER JOIN wp_terms AS wp_terms_1 ON wp_term_taxonomy_1.term_id = wp_terms_1.term_id
GROUP BY wp_term_taxonomy.term_taxonomy_id, wp_term_taxonomy.taxonomy, wp_terms.name, wp_terms.term_id, wp_terms.slug, wp_terms.term_group, wp_terms_1.slug
HAVING (((wp_term_taxonomy.taxonomy)='$my_tax') AND ((wp_terms_1.slug) = '$my_category'))
ORDER BY Count(wp_posts.ID) DESC";
$datos = $wpdb->get_results($query, OBJECT);
echo "<ul>";
$total = 0;
foreach ( $datos as $dato ) {
echo '<li><a href="' . get_bloginfo('url') . '/' . get_parent_page_slug() . '/' . $pagename . '/?tipo=' . $dato->term_slug . '">' . $dato->name . ' (' . $dato->my_term_count . ')</a></li>';
$total += $dato->my_term_count;
}
echo '<li><a href="' . get_bloginfo('url') . '/' . get_parent_page_slug() . '/' . $pagename . '/">Todos (' . $total . ')</a></li>';
echo "</ul>";
}
my_custom_get_terms( 'tipo', get_parent_page_slug() );
Edito: Sé acerca del uso de $wpdb->
tabla para sustituir el prefijo wp_
tabla, pero al implementarlo me dio problemas y que quedó así al menos momentáneamente.