tag_exists

函数
tag_exists ( $tag_name )
参数
  • (int|string) $tag_name
    Required:
返回值
  • (mixed) Returns null if the term does not exist. Returns an array of the term ID and the term taxonomy ID if the pairing exists. Returns 0 if term ID 0 is passed to the function.
定义位置
相关方法
post_existsterm_existsemail_existsmetadata_existscategory_exists
引入
2.3.0
弃用
-

tag_exists: 这是一个WordPress的函数,用于检查一个具有指定名称的标签是否存在: 这个函数只需要一个参数,即你想检查的标签名称。如果标签存在,这个函数返回标签的ID。如果标签不存在,该函数返回false。

检查具有给定名称的文章标签是否存在。

function tag_exists( $tag_name ) {
	return term_exists( $tag_name, 'post_tag' );
}

常见问题

FAQs
查看更多 >
闪电侠

(工作日 10:00 - 18:30 为您服务)

2025-12-05 16:32:56

您好,无论是售前、售后、意见建议……均可通过联系工单与我们取得联系。

您也可选择聊天工具与我们即时沟通或点击查看:

您的工单我们已经收到,我们将会尽快跟您联系!
取消
选择聊天工具: