On this page
wp_term_is_shared( int $term_id ): bool
Determines whether a term is shared between multiple taxonomies.
Description
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
$term_idint Required-
Term ID.
Return
bool Returns false if a term is not shared between multiple taxonomies or if splitting shared taxonomy terms is finished.
Source
File: wp-includes/taxonomy.php. View all references
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;
}
Related
Uses
| Uses | Description |
|---|---|
| get_option() wp-includes/option.php | Retrieves an option value based on an option name. |
| wpdb::get_var() wp-includes/class-wpdb.php | Retrieves one variable from the database. |
| wpdb::prepare() wp-includes/class-wpdb.php | Prepares a SQL query for safe execution. |
Used By
| Used By | Description |
|---|---|
| add_term_meta() wp-includes/taxonomy.php | Adds metadata to a term. |
| update_term_meta() wp-includes/taxonomy.php | Updates term metadata. |
Changelog
| Version | Description |
|---|---|
| 4.4.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_term_is_shared