get_linkcatname

函式
get_linkcatname ( $id = 0 )
引數
  • (int) $id The category to get. If no category supplied uses 0
    Required:
返回值
  • (string)
相關
  • get_category()
定義位置
相關方法
get_catnameget_cat_nameget_linksbynameget_linkobjectsbynameget_linkrating
引入
0.71
棄用
2.1.0

get_linkcatname: 這個函式用來檢索給定連結ID的連結類別的名稱。

通過ID獲取類別的名稱。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
function get_linkcatname($id = 0) {
_deprecated_function( __FUNCTION__, '2.1.0', 'get_category()' );
$id = (int) $id;
if ( empty($id) )
return '';
$cats = wp_get_link_cats($id);
if ( empty($cats) || ! is_array($cats) )
return '';
$cat_id = (int) $cats[0]; // Take the first cat.
$cat = get_category($cat_id);
return $cat->name;
}
function get_linkcatname($id = 0) { _deprecated_function( __FUNCTION__, '2.1.0', 'get_category()' ); $id = (int) $id; if ( empty($id) ) return ''; $cats = wp_get_link_cats($id); if ( empty($cats) || ! is_array($cats) ) return ''; $cat_id = (int) $cats[0]; // Take the first cat. $cat = get_category($cat_id); return $cat->name; }
function get_linkcatname($id = 0) {
	_deprecated_function( __FUNCTION__, '2.1.0', 'get_category()' );

	$id = (int) $id;

	if ( empty($id) )
		return '';

	$cats = wp_get_link_cats($id);

	if ( empty($cats) || ! is_array($cats) )
		return '';

	$cat_id = (int) $cats[0]; // Take the first cat.

	$cat = get_category($cat_id);
	return $cat->name;
}

常見問題

FAQs
檢視更多 >