wp_get_split_term

函数
wp_get_split_term ( $old_term_id, $taxonomy )
参数
  • (int) $old_term_id Term ID. This is the old, pre-split term ID.
    Required:
  • (string) $taxonomy Taxonomy that the term belongs to.
    Required:
返回值
  • (int|false) If a previously split term is found corresponding to the old term_id and taxonomy, the new term_id will be returned. If no previously split term is found matching the parameters, returns false.
定义位置
相关方法
wp_get_split_termswp_get_post_terms_wp_batch_split_termswp_set_post_termswp_get_sites
引入
4.2.0
弃用
-

wp_get_split_term: 这个函数为分层分类法中的某个术语检索父术语ID和当前术语ID。它接受两个参数 – 当前术语ID和分类法的名称。它返回一个有两个元素的数组–父术语ID和当前术语ID。

获取与之前拆分的术语对应的新术语ID。

function wp_get_split_term( $old_term_id, $taxonomy ) {
	$split_terms = wp_get_split_terms( $old_term_id );

	$term_id = false;
	if ( isset( $split_terms[ $taxonomy ] ) ) {
		$term_id = (int) $split_terms[ $taxonomy ];
	}

	return $term_id;
}

常见问题

FAQs
查看更多 >