get_cat_name

函式
get_cat_name ( $cat_id )
引數
  • (int) $cat_id Category ID.
    Required:
返回值
  • (string) Category name, or an empty string if the category doesn't exist.
定義位置
相關方法
get_catnameget_author_nameget_linkcatnameget_cat_idget_the_time
引入
1.0.0
棄用
-

get_cat_name:此函式根據類別ID檢索類別的名稱。它接受一個引數:$cat_ID,這是類別的ID。

從一個類別的ID中檢索該類別的名稱。

function get_cat_name( $cat_id ) {
	$cat_id   = (int) $cat_id;
	$category = get_term( $cat_id, 'category' );

	if ( ! $category || is_wp_error( $category ) ) {
		return '';
	}

	return $category->name;
}

常見問題

FAQs
檢視更多 >