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
檢視更多 >