首页 WordPress函数 WordPress检测分类法项目是否存在函数:term_exists
正文 评论

WordPress检测分类法项目是否存在函数:term_exists

WordPress函数term_exists用于检测分类法项目是否存在。

term_exists( int|string $term, string $taxonomy = \'\', int $parent = null )

函数参数

$term

字符串或整数

分类法项目的ID、别名或名称

$taxonomy

字符串

分类法名称,如果不指定,默认检测分类法category,返回检测的term ID,如果指定分类法名称,返回包含term_id和term_taxonomy_id的数组

$parent

整数

父分类ID

函数返回值

如果分类不存在,返回null,指定$taxonomy的值则返回包含term_id和term_taxonomy_id的数组,否则返回分类ID

函数使用示例

$term = term_exists(1);if($term !== 0 && $term !== null) {    echo \'分类存在\';}

扩展阅读

term_exists()函数位于:wp-includes/taxonomy.php

相关函数:

  • category_exists()
  • tag_exists()
  • wp_create_term()
  • wp_create_category()
  • wp_insert_category()
-=||=-收藏赞 (0)
更多主题
v1.0.0
小程序收录免费WordPress主题:XCX主题
¥ 0 关注:22,481
详情
单栏极简文艺WordPress博客主题:Diaspora主题
¥ 0 关注:22,055
详情
简约黑白WordPress个人博客主题:Personal主题
¥ 0 关注:21,760
详情
功能丰富切轻量的WordPress虚拟资源主题:Rizhuti主题
¥ 599 关注:19,807
详情
v1.0.0
一款简约单栏的免费WordPress博客主题:itheme主题
¥ 0 关注:19,737
详情
v3.4.0
适用自媒体资讯的免费WordPress主题:Autumn主题
¥ 0 关注:16,836
详情
回复
暂无评论

不要再留垃圾评论了,主题君整理资源不容易,留几句鼓励的话吧。