Support » Fixing WordPress » Tag counts incorrect in wp_term_taxonomy table

  • Resolved fr33think3r


    I created a custom post type and added post_tag and category as taxonomies for this custom post type. Now I created a few posts for this post_type, and added tags to it. When i go to the “edit_tags” page, the post count for the tag is zero. So I checked the database, and this is what I found.

    wp_term_relationships shows that the tag is associated with four posts, all posts of the same custom post type.


    However wp_term_taxonomy table shows 0 posts for the tag


    Code used to add the post type.

    $p2_custom_post_type = 'aside';
    $p2_custom_post_type_name = 'Asides';
    $p2_custom_post_type_singular_name = 'Aside';
    register_post_type( "$p2_custom_post_type",
                'labels' => array(
                'name' => __( "$p2_custom_post_type_name" ),
                'singular_name' => __( "$p2_custom_post_type_singular_name" )
                'public' => true,
                'supports' => array( 'title', 'editor', 'thumbnail', 'trackbacks', 'comments', 'custom-fields' ),
                'capability_type' => 'post',

    Added the taxonomy using the following code.

    register_taxonomy_for_object_type('category', $p2_custom_post_type);
    register_taxonomy_for_object_type('post_tag', $p2_custom_post_type);

    What am I doing wrong?

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Tag counts incorrect in wp_term_taxonomy table’ is closed to new replies.