カテゴリーIDまたはカテゴリーオブジェクトを指定したカテゴリーデータを取得します。
Retrieves category data given a category ID or category object.
$categoryパラメータのオブジェクトを渡した場合、カテゴリーのRowオブジェクトはデータベースを取得したと見なすでしょう。それはカテゴリーデータをキャッシュします。
If you pass the $category parameter an object, which is assumed to be the category row object retrieved the database. It will cache the category data.
カテゴリーIDの整数を$categoryに渡した場合、そのカテゴリーはデータベースから取得し、それが既にキャッシュされていない場合は、それを戻して渡します。
If you pass $category an integer of the category ID, then that category will be retrieved from the database, if it isn’t already cached, and pass it back.
get_term()を見れば、両方のタイプが幾つかのフィルターを通して渡され、最終的に$filterパラメータの値に基づいて削除されます。
If you look at get_term(), then both types will be passed through several filters and finally sanitized based on the $filter parameter value.
カテゴリーは下位互換性を維持するために変換されます。
The category will converted to maintain backwards compatibility.
注:それらのIDに基づいてカテゴリーリンクを取得するためにget_term()を使用します。get_category は投稿カテゴリーのみ返します。
Note: use get_term() to get Link Categories based on their ID’s. get_category only returns Post Categories.
get_categoryのファンクションタグ使用方法
<?php get_category( $category, $output, $filter ) ?>
get_categoryのパラメーター
$category
(integer|object) (required)カテゴリーIDまたはカテゴリーのROWオブジェクト。
デフォルト:なし
(integer|object) (required) Category ID or Category row object
Default: None
$output
(string) (optional)OBJECT, ARRAY_A, または ARRAY_Nの定数
デフォルト:OBJECT
(string) (optional) Constant OBJECT, ARRAY_A, or ARRAY_N
Default: OBJECT
$filter
(string) (optional) デフォルトはraw、あるいはWordPressに定義されたフィルターが適用されません。
デフォルト:’raw’
(string) (optional) Default is raw or no WordPress defined filter will applied.
Default: ‘raw’
戻り値
(mixed) $outputパラメータによって定義されたタイプ内のカテゴリーデータ
(mixed)
Category data in type defined by $output parameter.
例
カテゴリーデータを表示する方法
$thisCat = get_category(get_query_var('cat'),false);
print_r($thisCat);
生成します;
produces;
stdClass Object ( [term_id] => 85 [name] => Category Name [slug] => category-name [term_group] => 0 [term_taxonomy_id] => 85 [taxonomy] => category [description] => [parent] => 70 [count] => 0 [cat_ID] => 85 [category_count] => 0 [category_description] => [cat_name] => Category Name [category_nicename] => category-name [category_parent] => 70 )
注意
用途:get_term()はタクソノミーからカテゴリーデータを取得するために使用します。count属性はカスタム投稿タイプが標準的なカテゴリーを使用している場合と同様にカスタム投稿タイプを含みます。
Uses: get_term() Used to get the category data from the taxonomy.
The count attribute includes custom post types as well if the custom post type uses standard categories.
変更ログ
Since: 1.5.1
ソースファイル
get_category()は、wp-includes/category.php内に位置しています。
get_category() is located in wp-includes/category.php.