您的当前位置:首页 > 知识博客 > wordpress建站

WordPress根据分类名称获取分类ID函数:get_cat_ID

时间:2024-03-14

WordPress函数get_cat_ID可以根据分类的名称返回分类ID,在主题和插件的开发中很常用。

get_cat_ID( string $cat_name )

函数参数

$cat_name

字符串

分类的名称

函数使用示例

$cat_ID = get_cat_ID('开发');
$category = get_category($cat_ID);
echo '<a href="' . get_category_link($category->cat_ID) . '">' . $category->name . '</a>';

扩展阅读

get_cat_ID()函数位于:wp-includes/category.php

相关函数:

  • get_cat_name()

  • get_term_by()

  • get_category()

  • get_term()

  • get_category_children()

  • get_category_by_slug()

  • get_category_by_path()


欢迎咨询/Welcome to inquire
tel/vx:18842938855
qq:1685522781
email:1685522781@qq.com

Copyright © 2019-2024 sex.cyou


Whatsapp
Powered by RRZCMS