wp_term_is_shared

函数


wp_term_is_shared ( $term_id )
参数
  • (int)
    $term_id
    Term ID.
    Required:
返回值
  • (bool) Returns false if a term is not shared between multiple taxonomies or if splitting shared taxonomy terms is finished.
定义位置
  • wp-includes/taxonomy.php
    , line 4529
引入
4.4.0
弃用

确定一个术语是否在多个分类法之间共享。

共享的分类法术语在4.3版本中开始被拆分,但cron任务失败或升级程序的其他延迟可能导致共享的术语仍然存在。

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