the_category_head

函数
the_category_head ( $before = '', $after = '' )
参数
  • (string) $before Optional. Text to display before the category. Default empty.
    Required:
    Default: (empty)
  • (string) $after Optional. Text to display after the category. Default empty.
    Required:
    Default: (empty)
相关
  • get_the_category_by_ID()
定义位置
相关方法
the_category_idthe_categorythe_category_rssupdate_category_cacheget_the_category
引入
0.71
弃用
0.71.0

the_category_head – 这个函数用来在一个页面的HTML头部输出类别信息。它可以用来提供关于一个文章所属类别的元数据。

打印一个类别,前后有可选的文本。

function the_category_head( $before = '', $after = '' ) {
	global $currentcat, $previouscat;

	_deprecated_function( __FUNCTION__, '0.71', 'get_the_category_by_ID()' );

	// Grab the first cat in the list.
	$categories = get_the_category();
	$currentcat = $categories[0]->category_id;
	if ( $currentcat != $previouscat ) {
		echo $before;
		echo get_the_category_by_ID($currentcat);
		echo $after;
		$previouscat = $currentcat;
	}
}

常见问题

FAQs
查看更多 >
闪电侠

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

2025-12-06 05:33:10

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

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

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