wp_term_is_shared()
Determine if the term is shared across multiple taxonomies.
Shared taxonomy terms are automatically split since version 4.3, but failed cron jobs or other delays in update procedures may result in shared terms remaining.
Also read about the term splitting function wp_get_split_terms()
Used By: update_term_meta(), add_term_meta()
No Hooks.
Returns
true|false. Returns false if the term is not shared across multiple taxonomies or if the splitting of shared taxonomy terms is complete.
Usage
wp_term_is_shared( $term_id );
- $term_id(integer) (required)
- ID of the term.
Examples
#1 Check whether the term 123 is generic
$term_id = 123;
if( wp_term_is_shared( $term_id ) ){
echo "{$term_id} is a generic term";
}
Notes
- Global. wpdb.
$wpdbWordPress database abstraction object.
Changelog
| Since 4.4.0 | Introduced. |
wp_term_is_shared() wp term is shared code WP 7.0
function wp_term_is_shared( $term_id ) {
global $wpdb;
if ( get_option( 'finished_splitting_shared_terms' ) ) {
return false;
}
$tt_count = $wpdb->get_var( $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->term_taxonomy WHERE term_id = %d", $term_id ) );
return $tt_count > 1;
}