This plugin works fine - if you only use posts and pages.
If you also use a custom post type with tag-support (taxonomy: post_tag), the plugin breaks the process of updating the correct count of tags in database so other functionalities, e.g. Tag Clouds, get unexpected and wrong results.
The plugin overrides the default tag count update callback _update_post_term_count of taxonomy post_tag with a hardcoded sql-statement with only post types post and page so any other post type will not be updated.
Fix for Page Tagger 0.3.6, at end of file page-tagger-class.php
Old, only 2 hardcoded post_types:
function _update_post_term_count( $terms )
{
global $wpdb;
foreach ( (array) $terms as $term ) {
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND (post_type = 'post' OR post_type = 'page') AND term_taxonomy_id = %d", $term ) );
$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
}
}
New, add also custom post types to SELECT statement:
function _update_post_term_count( $terms )
{
global $wpdb;
foreach ( (array) $terms as $term ) {
$count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts WHERE $wpdb->posts.ID = $wpdb->term_relationships.object_id AND (post_type = 'post' OR post_type = 'page'" . $this->_get_custom_post_types_sql() . ") AND term_taxonomy_id = %d", $term ) );
$wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );
}
}
/* Hack for custom post types support */
function _get_custom_post_types_sql() {
$sql = '';
$cpt_arr = array();
$args = array(
'public' => true,
'_builtin' => false,
'taxonomies' => array('post_tag') // taxonomies actually not used, bug wp 3.2.1
);
$post_types = get_post_types($args, 'names');
foreach ($post_types as $post_type ) {
$cpt_arr[] = "post_type = '$post_type'";
}
if ($cpt_arr) {
$sql = ' OR ' . implode(' OR ', $cpt_arr);
}
return $sql;
}