WordPress主题函数get_the_category_by_ID()知识点

WordPress主题函数get_the_category_by_ID()知识点 (https://www.wp-admin.cn/) WordPress开发教程 第1张

WordPress主题函数get_the_category_by_ID()知识点。

描述:

通过分类id获取分类所有信息

用法:

<?php get_the_category_by_ID( $cat_ID ); ?>

参数:

$cat_ID

(int) (必填) 分类ID

默认值:None

源文件:

/**
* Retrieve category name based on category ID.
*
* @since 0.71
*
* @param int $cat_ID Category ID.
* @return string|WP_Error Category name on success, WP_Error on failure.
*/
function get_the_category_by_ID( $cat_ID ) {
$cat_ID = (int) $cat_ID;
$category = get_term( $cat_ID, ‘category’ );

if ( is_wp_error( $category ) )
return $category;

return ( $category ) ? $category->name : ”;
}

相关推荐

发表回复

房先生
我们将24小时内回复。
2024-05-11 06:09:59
您好,有任何疑问请与我们联系!
您的工单我们已经收到,我们将会尽快跟您联系!
[QQ客服]
2781198
加我微信
[电话联系]
13585372227
[电子邮件]
chaoneo@163.com
取消

选择聊天工具: