登録されているタクソノミーオブジェクトのリストを取得します。
Get a list of registered taxonomy objects.
get_taxonomiesのファンクションタグ使用方法
<?php get_taxonomies( $args, $output, $operator ) ?>
get_taxonomiesのパラメーター
$args
(array) (optional)キーの配列->値の引数は、タクソノミーを照合します。全ての引数に一致する属性を持っているタクソノミーのみ返します。
デフォルト:なし
(array) (optional) An array of key -> value arguments to match against the taxonomies. Only taxonomies having attributes that match all arguments are returned.
Default: None
- name
- object_type (array)
- label
- singular_label
- show_ui
- show_tagcloud
- public
- update_count_callback
- rewrite
- query_var
- manage_cap
- edit_cap
- delete_cap
- assign_cap
- _builtin
$output
(string) (optional)タクソノミーが’names’ か ‘objects’のいづれかで、返すために出力するタイプです。
デフォルト:’names’
(string) (optional) The type of output to return, either taxonomy ‘names’ or ‘objects’.
Default: ‘names’
$operator
(string) (optional)複数の$argsを使用するための演算子(and/or)。
デフォルト:and
(string) (optional) Operator (and/or) to use with multiple $args.
Default: and
戻り値
array
名前あるいはオブジェクトのタクソノミーのリスト。名前を返す場合、次のようなタクソノミー名の配列を取得します。
A list of taxonomy names or objects. If returning names, you will get an array of the taxonomy names such as
Array ( [special_taxonomy] => special_taxonomy [custom_taxonomy] => custom_taxonomy )
オブジェクトを帰す場合、次のようなオブジェクトの配列を取得します。
If returning objects, you will get an array of objects such as:
Array ( [special_taxonomy] => stdClass Object [custom_taxonomy] => stdClass Object )
ここでは、各オブジェクトは次のフィールドが含まれます:
wherein each object will contain the following fields:
stdClass Object ( [hierarchical] => [update_count_callback] => [rewrite] => [query_var] => [public] => [show_ui] => [show_tagcloud] => [_builtin] => [labels] => stdClass Object ( [name] => [singular_name] => [search_items] => [popular_items] => [all_items] => [parent_item] => [parent_item_colon] => [edit_item] => [view_item] => [update_item] => [add_new_item] => [new_item_name] => [separate_items_with_commas] => [add_or_remove_items] => [choose_from_most_used] => [menu_name] => [name_admin_bar] => ) [show_in_nav_menus] => [cap] => stdClass Object ( [manage_terms] => [edit_terms] => [delete_terms] => [assign_terms] => ) [name] => [object_type] => Array () [label] )
例
デフォルトの使用方法
get_taxonomiesを呼び出すために、登録されたタクソノミーを返します。
The call to get_taxonomies returns the registered taxonomies.
<?php $taxonomies=get_taxonomies(); ?>
全ての登録されたタクソノミーのリストを出力する方法
<?php $taxonomies=get_taxonomies('','names'); foreach ($taxonomies as $taxonomy ) { echo '<p>'. $taxonomy. '</p>'; } ?>
全ての公開しているカスタムタクソノミーのリストを出力する方法
この戻り値は、すべてのカスタム(ビルトインしていない)のタクソノミーです。
This return all custom (not builtin) taxonomies.
<?php $args=array( 'public' => true, '_builtin' => false ); $output = 'names'; // or objects $operator = 'and'; // 'and' or 'or' $taxonomies=get_taxonomies($args,$output,$operator); if ($taxonomies) { foreach ($taxonomies as $taxonomy ) { echo '<p>'. $taxonomy. '</p>'; } } ?>
名付けたタクソノミーを出力する方法
この例は、’genre’と呼ばれるタクソノミーを取得して表示するために、’object’ の出力を使用します。
This example uses the ‘object’ output to retrieve and display the taxonomy called ‘genre’:
<?php $args=array( 'name' => 'genre' ); $output = 'objects'; // or objects $taxonomies=get_taxonomies($args,$output); if ($taxonomies) { foreach ($taxonomies as $taxonomy ) { echo '<p>' . $taxonomy->name . '</p>'; } } ?>
ソースファイル
get_taxonomies()は、wp-includes/taxonomy.php内に位置しています。
get_taxonomies() is located in wp-includes/taxonomy.php.
変更ログ
Since: 3.0.0