the_category_id

函数
the_category_id ( $display = true )
参数
  • (bool) $display Optional. Whether to display the output. Default true.
    Required:
    Default: true
返回值
  • (int) Category ID.
相关
  • get_the_category()
定义位置
相关方法
the_categorythe_category_headthe_category_rssget_the_category_by_idthe_author_id
引入
0.71
弃用
0.71.0

the_category_id – 这个函数用来显示分配给一个文章的第一个类别的ID。它对需要知道某个特定文章的类别ID的开发者很有用。

返回或打印一个类别ID。

function the_category_ID($display = true) {
	_deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' );

	// Grab the first cat in the list.
	$categories = get_the_category();
	$cat = $categories[0]->term_id;

	if ( $display )
		echo $cat;

	return $cat;
}

常见问题

FAQs
查看更多 >
闪电侠

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

2026-01-29 00:09:24

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

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

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