From f4d5f4fcebcc8034936f8b0d89e9fbfd4e93e02d Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 20 Oct 2011 14:28:26 +0000 Subject: [PATCH] Fix term counting for links. Props SergeyBiryukov. fixes #18986 git-svn-id: https://develop.svn.wordpress.org/trunk@19025 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/taxonomy.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 6d627591e7..d403435436 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -2855,8 +2855,10 @@ function _update_post_term_count( $terms, $taxonomy ) { // Attachments can be 'inherit' status, we need to base count off the parent's staus if so if ( in_array( 'attachment', $object_types ) ) $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships, $wpdb->posts p1 WHERE p1.ID = $wpdb->term_relationships.object_id AND ( post_status = 'publish' OR ( post_status = 'inherit' AND post_parent > 0 AND ( SELECT post_status FROM $wpdb->posts WHERE ID = p1.post_parent ) = 'publish' ) ) AND post_type IN ('" . implode("', '", $object_types) . "') AND term_taxonomy_id = %d", $term ) ); - else + elseif ( post_type_exists( $object_type ) ) $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_status = 'publish' AND post_type IN ('" . implode("', '", $object_types) . "') AND term_taxonomy_id = %d", $term ) ); + else + $count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_relationships WHERE term_taxonomy_id = %d", $term ) ); do_action( 'edit_term_taxonomy', $term, $taxonomy ); $wpdb->update( $wpdb->term_taxonomy, compact( 'count' ), array( 'term_taxonomy_id' => $term ) );