wp_term_is_shared

Determine whether a term is shared between multiple taxonomies.

Description

wp_term_is_shared( (int) $term_id ); 

Shared taxonomy terms began to be split in 4.3, but failed cron tasks or other delays in upgrade routines may cause shared terms to remain.

Parameters (1)

0. $term_id (int)
The term id.

Usage

  1. if ( !function_exists( 'wp_term_is_shared' ) ) { 
  2. require_once ABSPATH . WPINC . '/taxonomy.php'; 
  3.  
  4. // The term id. 
  5. $term_id = -1; 
  6.  
  7. // NOTICE! Understand what this does before running. 
  8. $result = wp_term_is_shared($term_id); 
  9.  

Defined (1)

The function is defined in the following location(s).

/wp-includes/taxonomy.php  
  1. function wp_term_is_shared( $term_id ) { 
  2. global $wpdb; 
  3.  
  4. if ( get_option( 'finished_splitting_shared_terms' ) ) { 
  5. return false; 
  6.  
  7. $tt_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id ) ); 
  8.  
  9. return $tt_count > 1;