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

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

「関数リファレンス/get object taxonomies」の版間の差分

提供: WordPress Codex 日本語版
移動先: 案内検索
(en:Function Reference/get object taxonomies 09:38, 21 August 2013 Saurabhshukla 版)
 
(和訳の準備のみ。)
1行目: 1行目:
 +
{{NeedTrans}}
 +
 
== Description ==
 
== Description ==
 
Returns all the taxonomies for a post type or post object
 
Returns all the taxonomies for a post type or post object
  
 
== Usage ==
 
== Usage ==
%%%<?php get_object_taxonomies( $object, $output ); ?>%%%
+
<pre>
 +
<?php get_object_taxonomies( $object, $output ); ?>
 +
</pre>
  
 
== Parameters ==
 
== Parameters ==
16行目: 20行目:
 
=== Taxonomy names for post type ===
 
=== Taxonomy names for post type ===
 
<pre>
 
<pre>
&lt;?php  
+
<?php  
  
 
   $taxonomy_names = get_object_taxonomies( 'post' );
 
   $taxonomy_names = get_object_taxonomies( 'post' );
 
   print_r( $taxonomy_names);
 
   print_r( $taxonomy_names);
  
?&gt;
+
?>
 
</pre>
 
</pre>
  
27行目: 31行目:
  
 
<pre>
 
<pre>
 
 
Array
 
Array
 
(
 
(
34行目: 37行目:
 
     [2] => post_format
 
     [2] => post_format
 
)
 
)
 
 
</pre>
 
</pre>
  
42行目: 44行目:
  
 
<pre>
 
<pre>
&lt;?php  
+
<?php  
  
 
   $taxonomy_objects = get_object_taxonomies( 'post', 'objects' );
 
   $taxonomy_objects = get_object_taxonomies( 'post', 'objects' );
 
   print_r( $taxonomy_objects);
 
   print_r( $taxonomy_objects);
  
?&gt;
+
?>
 
</pre>
 
</pre>
  
93行目: 95行目:
  
 
<pre>
 
<pre>
&lt;?php  
+
<?php  
  
 
     function get_current_post_taxonomies(){
 
     function get_current_post_taxonomies(){
104行目: 106行目:
 
     add_action('wp_head','get_current_post_taxonomies');
 
     add_action('wp_head','get_current_post_taxonomies');
  
?&gt;
+
?>
 
</pre>
 
</pre>
  
110行目: 112行目:
  
 
<pre>
 
<pre>
 
 
Array
 
Array
 
(
 
(
117行目: 118行目:
 
     [2] => post_format
 
     [2] => post_format
 
)
 
)
 
 
</pre>
 
</pre>
  
128行目: 128行目:
 
== Related ==
 
== Related ==
 
*[[Function_Reference/get_taxonomies | get_taxonomies() ]]
 
*[[Function_Reference/get_taxonomies | get_taxonomies() ]]
{{Term Tags}}
+
{{Taxonomy Tags}}
 
{{Tag Footer}}
 
{{Tag Footer}}
  
[[Category:Functions]]
+
{{原文|Function Reference/get object taxonomies|134714}} <!-- 09:38, 21 August 2013 Saurabhshukla -->
 +
 
 +
{{DEFAULTSORT:Get_object_taxonomies}}
 +
[[Category:関数]]
 +
[[Category:タクソノミー]]
 +
 
 +
[[en:Function Reference/get object taxonomies]]

2014年7月6日 (日) 01:22時点における版

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

Description

Returns all the taxonomies for a post type or post object

Usage

<?php get_object_taxonomies( $object, $output ); ?>

Parameters

$object
array|string|object) (必須) Name of the post type, or a post object (row from posts)
初期値: なし
$output
string) (optional) The type of output to return, either taxonomy 'names' or 'objects'.
初期値: 'names'

Return Values

(array) 
All taxonomy names or objects for the given post type/post object

Examples

Taxonomy names for post type

<?php 

   $taxonomy_names = get_object_taxonomies( 'post' );
   print_r( $taxonomy_names);

?>

will typically output:

Array
(
    [0] => category
    [1] => post_tag
    [2] => post_format
)

Taxonomy objects for post type

If the $output parameter is 'objects', taxonomy objects will be returned as described in get_taxonomies()

<?php 

   $taxonomy_objects = get_object_taxonomies( 'post', 'objects' );
   print_r( $taxonomy_objects);

?>

will output

Array
(
    [category] => stdClass Object
        (
            [hierarchical] => 1
            [update_count_callback] => 
            [rewrite] => 
            [query_var] => category_name
            [public] => 1
            [show_ui] => 1
            [show_tagcloud] => 1
            [_builtin] => 1
            [labels] => stdClass Object
                (
                    ...
                )

            ...

            [name] => category
            [label] => Categories
        )

    [post_tag] => stdClass Object
        (
            ...
        )

    [post_format] => stdClass Object
        (
            ....
        )

)

Taxonomy names for post object

To get the taxonomies for the current post, the current post object can be passed instead of the post type

<?php 

    function get_current_post_taxonomies(){
        global $post;

        $taxonomy_names = get_object_taxonomies( $post );
        print_r( $taxonomy_names );
    }

    add_action('wp_head','get_current_post_taxonomies');

?>

will output

Array
(
    [0] => category
    [1] => post_tag
    [2] => post_format
)

Change Log

Since: 2.3.0

Source File

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

Related

カスタム分類: 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 object taxonomies最新版との差分