wp_term_is_shared() WordPress Function

The wp_term_is_shared() function is used to check if a term is shared between multiple taxonomies. This function is useful for checking if a term is shared between custom taxonomies and built-in taxonomies.

wp_term_is_shared( int $term_id ) #

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.


Top ↑

Parameters

$term_id

(int)(Required)Term ID.


Top ↑

Return

(bool) Returns false if a term is not shared between multiple taxonomies or if splitting shared taxonomy terms is finished.


Top ↑

Source

File: wp-includes/taxonomy.php

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;
}


Top ↑

Changelog

Changelog
VersionDescription
4.4.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.

Show More
Show More