函数文档

is_term()

💡 云策文档标注

概述

is_term() 函数用于检查术语是否存在,但自 WordPress 3.0.0 起已被弃用,建议使用 term_exists() 替代。

关键要点

  • is_term() 函数已弃用,应改用 term_exists() 函数。
  • 函数接受三个参数:$term(术语标识)、$taxonomy(分类法名称)和 $parent(父术语ID)。
  • 返回术语ID或术语对象(如果存在),否则返回 null。

注意事项

  • is_term() 在 WordPress 3.0.0 中被标记为弃用,使用时会触发 _deprecated_function() 警告。
  • 相关函数包括 term_exists() 和 _deprecated_function()。

📄 原文内容

Check if Term exists.

Description

See also

Parameters

$termint|stringrequired
The term to check
$taxonomystringrequired
The taxonomy name to use
$parentintrequired
ID of parent term under which to confine the exists search.

Return

mixed Get the term ID or term object, if exists.

Source

function is_term( $term, $taxonomy = '', $parent = 0 ) {
	_deprecated_function( __FUNCTION__, '3.0.0', 'term_exists()' );
	return term_exists( $term, $taxonomy, $parent );
}

Changelog

Version Description
3.0.0 Deprecated. Use term_exists()
2.3.0 Introduced.