- 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細)
「関数リファレンス/get taxonomies」の版間の差分
提供: WordPress Codex 日本語版
< 関数リファレンス
(初めての翻訳。) |
細 (関連情報を Term から Taxonomies へ変更。) |
||
153行目: | 153行目: | ||
== 関連情報 == | == 関連情報 == | ||
− | {{Term Tags}} | + | {{Taxonomy Tags}} |
+ | <!-- {{Term Tags}} --> | ||
{{Tag Footer}} | {{Tag Footer}} | ||
159行目: | 160行目: | ||
{{原文|Function_Reference/get_taxonomies|127496}}<!--19:02, 18 February 2013 Veraxus --> | {{原文|Function_Reference/get_taxonomies|127496}}<!--19:02, 18 February 2013 Veraxus --> | ||
− | [[Category: | + | [[Category:テンプレートタグ]] |
− | [[Category: | + | [[Category:タクソノミー]] |
[[en:Function_Reference/get_taxonomies]] | [[en:Function_Reference/get_taxonomies]] |
2014年7月5日 (土) 22:08時点における版
目次
解説
登録済みタクソノミーのオブジェクトのリストを取得します。
使用例
<?php get_taxonomies( $args, $output, $operator ) ?>
引数
- $args
- (配列) (オプション) タクソノミーを検索する為の「キー -> 値」の配列です。すべての引数にマッチするタクソノミーだけを取得します。
- 初期値: なし
以下のキーが使えます。
- name
- object_type (配列)
- label
- singular_label
- show_ui
- show_tagcloud
- public
- update_count_callback
- rewrite
- query_var
- manage_cap
- edit_cap
- delete_cap
- assign_cap
- _builtin
- $output
- (文字列) (オプション) 出力形式を指定します。タクソノミーの 'names' または 'objects' です。
- 初期値: 'names'
- $operator
- (文字列) (オプション) $args に引数を2つ以上入れた場合の結合方法 ( and または or ) です。
- 初期値: and
戻り値
- 配列
- タクソノミーの名前またはオブジェクトのリスト。名前の場合、タクソノミーの名前を次のような配列として取得します。
Array ( [special_taxonomy] => special_taxonomy [custom_taxonomy] => custom_taxonomy )
オブジェクトの場合、次のようなオブジェクトの配列になります。
Array ( [special_taxonomy] => stdClass Object [custom_taxonomy] => stdClass Object )
オブジェクトはそれぞれ、以下のようなフィールドを持ちます。
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 は登録済みタクソノミーを返します。
<?php $taxonomies=get_taxonomies(); ?>
すべての登録済みタクソノミーのリストを出力
<?php $taxonomies=get_taxonomies('','names'); foreach ($taxonomies as $taxonomy ) { echo '<p>'. $taxonomy. '</p>'; } ?>
すべてのカスタムタクソノミーのリストを出力
次のように呼び出すと、すべてのカスタムタクソノミー(組み込みのものを除く)を返します。
<?php $args = array( 'public' => true, '_builtin' => false ); $output = 'names'; $operator = 'and'; $taxonomies = get_taxonomies( $args, $output, $operator ); if ( $taxonomies ) { foreach ( $taxonomies as $taxonomy ) { echo '<p>' . $taxonomy . '</p>'; } } ?>
名前を指定してタクソノミーを出力
以下の例は 'object' 形式の出力を取得して、 'genre' という名前のタクソノミーを表示します。
<?php $args=array( 'name' => 'genre' ); $output = 'objects'; $taxonomies = get_taxonomies( $args, $output ); if ( $taxonomies ) { foreach ( $taxonomies as $taxonomy ) { echo '<p>' . $taxonomy->name . '</p>'; } } ?>
ソースファイル
get_taxonomies() は wp-includes/taxonomy.php
にあります。
変更履歴
- 3.0.0 から導入されました。
関連情報
カスタム分類: get_taxonomy(), taxonomy_exists(), register_taxonomy(), get_taxonomies(), the_taxonomies(), get_taxonomy_labels(), get_taxonomy_template(), is_object_in_taxonomy(), get_the_taxonomies(), get_post_taxonomies(), get_object_taxonomies(), is_taxonomy_hierarchical()
関数リファレンス、テンプレートタグ目次もご覧ください。
最新英語版: WordPress Codex » Function_Reference/get_taxonomies (最新版との差分)