get_the_category_by_ID() - WordPress 函数参考中文文档

返回介绍

get_the_category_by_ID()

发布于 2017-09-11 字数1308 浏览 855 评论 0

get_the_category_by_ID( int $cat_ID )

Retrieve category name based on category ID.


描述


参数

$cat_ID

(int)
(Required)
Category ID.


返回值

(string|WP_Error) Category name on success, WP_Error on failure.


源代码

File: wp-includes/category-template.php

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 : '';
}

更新日志

Version 描述
0.71 Introduced.

相关函数

Uses

  • wp-includes/taxonomy.php:
    get_term()
  • wp-includes/load.php:
    is_wp_error()

Used By

  • wp-includes/deprecated.php:
    the_category_head()

User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!