• 赤色のリンクは、まだ日本語Codexに存在しないページ・画像です。英語版と併せてご覧ください。(詳細

このWikiはいつでも誰でも編集できます

関数リファレンス/get taxonomies

提供: WordPress Codex 日本語版
< 関数リファレンス
2014年6月9日 (月) 20:19時点におけるGblsm (トーク | 投稿記録)による版 (言語間リンクのみ修正。)

移動先: 案内検索

このページ「関数リファレンス/get taxonomies」は未翻訳です。和訳や日本語情報を加筆してくださる協力者を求めています

Description

Get a list of registered taxonomy objects.

Usage

%%% <?php get_taxonomies( $args, $output, $operator ) ?> %%%

Parameters

$args
array) (optional) An array of key -> value arguments to match against the taxonomies. Only taxonomies having attributes that match all arguments are returned.
初期値: なし
  • 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) The type of output to return, either taxonomy 'names' or 'objects'.
初期値: 'names'
$operator
string) (optional) Operator (and/or) to use with multiple $args.
初期値: and

Return Value

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]  )

Examples

Default Usage

The call to get_taxonomies returns the registered taxonomies.

<?php $taxonomies=get_taxonomies(); ?>

Output a list all registered taxonomies

<?php 
$taxonomies=get_taxonomies('','names'); 
foreach ($taxonomies as $taxonomy ) {
  echo '<p>'. $taxonomy. '</p>';
}
?>

Output a list of all public custom taxonomies

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>';
  }
}
?>

Output a named taxonomy

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>';
  }
}  
?>

Source File

get_taxonomies() is located in wp-includes/taxonomy.php.

Change Log

  • Since: 3.0.0

Related

タームタグ: is_term(), term_exists(), get_objects_in_term(), get_term(), get_term_by(), get_term_children(), get_term_link(), get_terms(), get_the_terms(), get_the_term_list(), has_term(), sanitize_term(), the_terms(), get_object_taxonomies() is_object_in_taxonomy() the_taxonomies() wp_get_object_terms(), wp_set_object_terms(), wp_get_post_terms(), wp_set_post_terms(), wp_delete_object_term_relationships()



関数リファレンステンプレートタグ目次もご覧ください。


最新英語版: WordPress Codex » Function_Reference/get_taxonomies最新版との差分