Custom Taxonomies Incorrectly Counting Revisions?

Hi @berkleebassist:

It’s hard to verify your issue without admin access to your site and your database but I can give you some direction that might help.

There are two functions in /wp-includes/taxonomy.php that update taxonomy term count: wp_update_term_count_now() and _update_post_term_count(). They are located (in WordPress v3.0.1) at line 2454 and line 2049, respectively. Both of them call an action hook 'edited_term_taxonomy' just after they have updated the count. Both functions send the same two parameters a $term and a $taxonomy so you can treat this as just one hook to program.

Here’s a shell of a function you can copy to your theme’s functions.php file to update the count, just add the SQL that UPDATEs the count how you want it to be updated:

add_action('edited_term_taxonomy','yoursite_edited_term_taxonomy',10,2);
function yoursite_edited_term_taxonomy($term,$taxonomy) {
  global $wpdb;
  $sql = "...set this to UPDATE taxonomy term count how you want...";
  $wpdb->query($sql);
}

Let me know if you need more specific direction about writing the SQL command.

Also, here’s a trac ticket that discusses something similar; it may be related:

Leave a Comment