diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php
index 1a0d170848..f89fb7d8d7 100644
--- src/wp-includes/taxonomy.php
+++ src/wp-includes/taxonomy.php
@@ -2916,6 +2916,65 @@ function wp_update_term_count_now( $terms, $taxonomy ) {
 	return true;
 }
 
+/**
+ * Retrieves the term count for a specific object type.
+ *
+ * @since 4.9.0
+ *
+ * @param int    $term_id     Term ID.
+ * @param string $taxonomy    Taxonomy name.
+ * @param string $object_type Object type.
+ *
+ * @return WP_Error|bool|int WP_Error if invalid taxonomy is passed.
+ *                           False if object is not in taxonomy.
+ *                           Object term count otherwise.
+ */
+function wp_get_term_count_for_object_type( $term_id, $taxonomy, $object_type ) {
+	if ( ! taxonomy_exists( $taxonomy ) ) {
+		return new WP_Error( 'invalid_taxonomy', __( 'Invalid taxonomy.' ) );
+	}
+
+	if ( ! is_object_in_taxonomy( $object_type, $taxonomy ) ) {
+		return false;
+	}
+
+	$term = get_term( $term_id, $taxonomy );
+
+	if ( 0 === $term->count ) {
+		return 0;
+	}
+
+	$taxonomy_object = get_taxonomy( $taxonomy );
+
+	if ( 1 >= count( $taxonomy_object->object_type ) ) {
+		return $term->count;
+	}
+
+	$term_object_count = get_term_meta( $term_id, '_wp_object_count_' . $object_type, true );
+	if ( $term_object_count ) {
+		return (int) $term_object_count;
+	}
+
+	$counted_object_types = (array) get_term_meta( $term_id, '_wp_counted_object_types', true );
+
+	/*
+	 * If the object type has been counted, and other counts exist in meta, we can
+	 * assume this term has 0 relationships for this object type.
+	 */
+	if ( in_array( $object_type, $counted_object_types, true ) ) {
+		foreach ( $taxonomy_object->object_type as $type ) {
+			if ( $test_meta = get_term_meta( $term_id, '_wp_object_count_' . $type, true ) ) {
+				return 0;
+			}
+		}
+	}
+
+	// No other meta caches existed. Count and try again.
+	if ( wp_update_term_count_now( array( $term_id ), $taxonomy ) ) {
+		return wp_get_term_count_for_object_type( $term_id, $taxonomy, $object_type );
+	}
+}
+
 //
 // Cache
 //
@@ -3412,8 +3471,9 @@ function _update_post_term_count( $terms, $taxonomy ) {
 
 	$object_types = (array) $taxonomy->object_type;
 
-	foreach ( $object_types as &$object_type )
+	foreach ( $object_types as &$object_type ) {
 		list( $object_type ) = explode( ':', $object_type );
+	}
 
 	$object_types = array_unique( $object_types );
 
@@ -3422,18 +3482,60 @@ function _update_post_term_count( $terms, $taxonomy ) {
 		$check_attachments = true;
 	}
 
-	if ( $object_types )
+	if ( $object_types ) {
 		$object_types = esc_sql( array_filter( $object_types, 'post_type_exists' ) );
+	}
 
 	foreach ( (array) $terms as $term ) {
 		$count = 0;
 
+		// Remove previous counts to prevent stale data if an object type is removed from a taxonomy.
+		$counted_object_types = (array) get_term_meta( $term, '_wp_counted_object_types', true );
+
+		foreach ( $counted_object_types as $o_type ) {
+			delete_term_meta( $term, '_wp_object_count_' . $o_type );
+		}
+
+		delete_term_meta( $term, '_wp_counted_object_types' );
+
+		$term_count_meta = array();
+
+		if ( $object_types ) {
+			foreach ( $object_types as $type ) {
+				$current_count = (int) $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 = %s AND term_taxonomy_id = %d", $type, $term ) );
+
+				$count += $current_count;
+				$term_count_meta[ $type ] = $current_count;
+			}
+		}
+
 		// Attachments can be 'inherit' status, we need to base count off the parent's status if so.
-		if ( $check_attachments )
-			$count += (int) $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 = 'attachment' AND term_taxonomy_id = %d", $term ) );
+		if ( $check_attachments ) {
+			$attachment_count = (int) $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 = 'attachment' AND term_taxonomy_id = %d", $term ) );
+
+			$count += $attachment_count;
+			$term_count_meta['attachment'] = $attachment_count;
 
-		if ( $object_types )
-			$count += (int) $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 ) );
+			// Re-add attachment so the meta gets saved below.
+			$object_types[] = 'attachment';
+		}
+
+		// Save individual counts for each object type in term meta.
+		if ( 1 < count( $term_count_meta ) ) {
+			foreach ( $object_types as $type ) {
+				if ( ! empty( $term_count_meta[ $type ] ) ) {
+					update_term_meta( $term, '_wp_object_count_' . $type, (int) $term_count_meta[ $type ] );
+				}
+			}
+
+			update_term_meta( $term, '_wp_counted_object_types', $object_types );
+		} else {
+			foreach ( $object_types as $type ) {
+				delete_term_meta( $term, '_wp_object_count_' . $type );
+			}
+
+			delete_term_meta( $term, '_wp_counted_object_types' );
+		}
 
 		/** This action is documented in wp-includes/taxonomy.php */
 		do_action( 'edit_term_taxonomy', $term, $taxonomy->name );
@@ -3861,7 +3963,7 @@ function wp_get_split_term( $old_term_id, $taxonomy ) {
  *
  * @param int $term_id Term ID.
  * @return bool Returns false if a term is not shared between multiple taxonomies or
- *              if splittng shared taxonomy terms is finished. 
+ *              if splittng shared taxonomy terms is finished.
  */
 function wp_term_is_shared( $term_id ) {
 	global $wpdb;
diff --git tests/phpunit/tests/term/getTerms.php tests/phpunit/tests/term/getTerms.php
index 575e5ca1c0..881c67a467 100644
--- tests/phpunit/tests/term/getTerms.php
+++ tests/phpunit/tests/term/getTerms.php
@@ -228,9 +228,9 @@ class Tests_Term_getTerms extends WP_UnitTestCase {
 		), $terms_id_slug );
 	}
 
- 	/**
+	/**
 	 * @ticket 11823
- 	 */
+	 */
 	function test_get_terms_include_exclude() {
 		global $wpdb;
 
@@ -2219,6 +2219,110 @@ class Tests_Term_getTerms extends WP_UnitTestCase {
 		$this->assertNotEquals( 'foo', $found );
 	}
 
+	/**
+	 * @ticket 38280
+	 */
+	public function test_wp_get_term_count_for_object_type_single_object_type() {
+		$term_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) );
+		$post_id = self::factory()->post->create( array( 'post_type' => 'post' ) );
+
+		wp_set_object_terms( $post_id, array( $term_id ), 'category' );
+
+		$this->assertEquals( 1, wp_get_term_count_for_object_type( $term_id, 'category', 'post' ) );
+        $this->assertFalse( (bool) get_term_meta( $term_id, '_wp_counted_object_types', true ) );
+
+		$term_object = get_term( $term_id, 'category' );
+		$this->assertEquals( 1, $term_object->count );
+
+		wp_remove_object_terms( $post_id, array( $term_id ), 'category' );
+
+		$this->assertEquals( 0, wp_get_term_count_for_object_type( $term_id, 'category', 'post' ) );
+	}
+
+	/**
+	 * @ticket 38280
+	 */
+	public function test_wp_get_term_count_for_object_type_multiple_object_types() {
+		register_post_type( 'wptests_cpt' );
+		register_taxonomy_for_object_type( 'category', 'wptests_cpt' );
+
+		$term_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) );
+		$post_id = self::factory()->post->create( array( 'post_type' => 'post' ) );
+		$custom_post_id = self::factory()->post->create( array( 'post_type' => 'wptests_cpt' ) );
+
+		$this->assertEquals( 0, wp_get_term_count_for_object_type( $term_id, 'category', 'post' ) );
+		$this->assertEquals( 0,  wp_get_term_count_for_object_type( $term_id, 'category', 'wptests_cpt' ) );
+        $this->assertEmpty( get_term_meta( $term_id, '_wp_counted_object_types', true ) );
+
+		wp_set_object_terms( $post_id, array( $term_id ), 'category' );
+
+		$this->assertEquals( 1, wp_get_term_count_for_object_type( $term_id, 'category', 'post' ) );
+		$this->assertEquals( 0, wp_get_term_count_for_object_type( $term_id, 'category', 'wptests_cpt' ) );
+		$this->assertEquals( array( 'post', 'wptests_cpt' ), get_term_meta( $term_id, '_wp_counted_object_types', true ) );
+
+		wp_set_object_terms( $custom_post_id, array( $term_id ), 'category' );
+
+		$this->assertEquals( 1, wp_get_term_count_for_object_type( $term_id, 'category', 'post' ) );
+		$this->assertEquals( 1, wp_get_term_count_for_object_type( $term_id, 'category', 'wptests_cpt' ) );
+        $this->assertEquals( array( 'post', 'wptests_cpt' ), get_term_meta( $term_id, '_wp_counted_object_types', true ) );
+
+		$term_object = get_term( $term_id, 'category' );
+		$this->assertEquals( 2, $term_object->count );
+
+		wp_remove_object_terms( $custom_post_id, array( $term_id ), 'category' );
+
+		$this->assertEquals( 1, wp_get_term_count_for_object_type( $term_id, 'category', 'post' ) );
+		$this->assertEquals( 0, wp_get_term_count_for_object_type( $term_id, 'category', 'wptests_cpt' ) );
+        $this->assertEquals( array( 'post', 'wptests_cpt' ), get_term_meta( $term_id, '_wp_counted_object_types', true ) );
+
+		wp_remove_object_terms( $post_id, array( $term_id ), 'category' );
+
+		$this->assertEquals( 0, wp_get_term_count_for_object_type( $term_id, 'category', 'post' ) );
+		$this->assertEquals( 0, wp_get_term_count_for_object_type( $term_id, 'category', 'wptests_cpt' ) );
+        $this->assertEquals( array( 'post', 'wptests_cpt' ), get_term_meta( $term_id, '_wp_counted_object_types', true ) );
+    }
+
+	/**
+	 * @ticket 38280
+	 */
+	public function test_wp_get_term_count_for_object_type_multiple_object_types_attachment() {
+		register_taxonomy_for_object_type( 'category', 'attachment' );
+
+		$term_id = self::factory()->term->create( array( 'taxonomy' => 'category' ) );
+		$post_id = self::factory()->post->create( array( 'post_type' => 'post' ) );
+		$attachment_id = self::factory()->attachment->create_upload_object( DIR_TESTDATA . '/images/canola.jpg', $post_id );
+
+		$this->assertEmpty( wp_get_term_count_for_object_type( $term_id, 'category', 'post' ) );
+		$this->assertEmpty( wp_get_term_count_for_object_type( $term_id, 'category', 'attachment' ) );
+        $this->assertEmpty( get_term_meta( $term_id, '_wp_counted_object_types', true ) );
+
+		wp_set_object_terms( $post_id, array( $term_id ), 'category' );
+
+		$this->assertEquals( 1, wp_get_term_count_for_object_type( $term_id, 'category', 'post' ) );
+		$this->assertEquals( 0, wp_get_term_count_for_object_type( $term_id, 'category', 'attachment' ) );
+        $this->assertEquals( array( 'post', 'attachment' ), get_term_meta( $term_id, '_wp_counted_object_types', true ) );
+
+		wp_set_object_terms( $attachment_id, array( $term_id ), 'category' );
+
+		$this->assertEquals( 1, wp_get_term_count_for_object_type( $term_id, 'category', 'post' ) );
+		$this->assertEquals( 1, wp_get_term_count_for_object_type( $term_id, 'category', 'attachment' ) );
+        $this->assertEquals( array( 'post', 'attachment' ), get_term_meta( $term_id, '_wp_counted_object_types', true ) );
+
+		$term_object = get_term( $term_id, 'category' );
+		$this->assertEquals( 2, $term_object->count );
+
+		wp_remove_object_terms( $attachment_id, array( $term_id ), 'category' );
+
+		$this->assertEquals( 1, wp_get_term_count_for_object_type( $term_id, 'category', 'post' ) );
+		$this->assertEquals( 0, wp_get_term_count_for_object_type( $term_id, 'category', 'attachment' ) );
+
+		wp_remove_object_terms( $post_id, array( $term_id ), 'category' );
+
+		$this->assertEquals( 0, wp_get_term_count_for_object_type( $term_id, 'category', 'post' ) );
+		$this->assertEquals( 0, wp_get_term_count_for_object_type( $term_id, 'category', 'attachment' ) );
+        $this->assertEquals( array( 'post', 'attachment' ), get_term_meta( $term_id, '_wp_counted_object_types', true ) );
+	}
+
 	public static function maybe_filter_count() {
 		return 'foo';
 	}
