当サイト、Codex 日本語版は今後積極的な更新は行わない予定です。後継となる新ユーザーマニュアルは、https://ja.wordpress.org/support/ にあります。
万が一、当サイトで重大な問題を発見した際などは、フォーラムWordSlack #docs チャンネルでお知らせください。</p>

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

提供: WordPress Codex 日本語版
移動先: 案内検索
(http://codex.wordpress.org/Function_Reference/get_the_terms 2011年2月8日 (火) 09:53 Coldzero1120)
 
(en:Function Reference/get term 19:41, 9 November 2013 Jdgrimes 版を流し込み。)
1行目: 1行目:
<div id="Description">
+
{{NeedTrans}}
== 解説 ==
+
</div>
+
  
投稿に割り当てられたタクソノミーを取得する。この関数はループ内でのみ使用される。〔※訳注 ループ外でも使用できる〕
+
== Description ==
 +
Get all Term data from database by Term ID. To retrieve term data by name, slug or ID, use [[関数リファレンス/get_term_by|get_term_by()]] instead
  
<div id="Usage">
+
The usage of the get_term function is to apply filters to a term object. It is possible to get a term object from the database before applying the filters.
== 使用例 ==
+
</div>
+
  
<pre>
+
<tt>$term</tt> ID must be part of <tt>$taxonomy</tt>, to get from the database. Failure, might be able to be captured by the hooks. Failure would be the same value as [[クラスリファレンス/wpdb|<tt>$wpdb</tt>]] returns for the get_row method.
&laquo;? php get_the_terms( $id, $taxonomy ) ?&raquo;
+
</pre>
+
  
<div id="Parameters">
+
There are two hooks, one is specifically for each term, named '<tt>get_term</tt>', and the second is for the taxonomy name, '<tt>term_$taxonomy</tt>'. Both hooks gets the term object, and the taxonomy name as parameters. Both hooks are expected to return a Term object.
== 引数 ==
+
</div>
+
  
{{Parameter|$id|int|投稿ID|必須|0}}
+
'<tt>get_term</tt>' hook - Takes two parameters the term Object and the taxonomy name. Must return term object. Used in [[関数リファレンス/get_term|<tt>get_term()</tt>]] as a catch-all filter for every <tt>$term</tt>.
{{Parameter|$taxonomy|string|タクソノミー名}}
+
  
<div id="Returns">
+
'<tt>get_$taxonomy</tt>' hook - Takes two parameters the term Object and the taxonomy name. Must return term object. <tt>$taxonomy</tt> will be the taxonomy name, so for example, if '<tt>category</tt>', it would be '<tt>get_category</tt>' as the filter name. Useful for custom taxonomies or plugging into default taxonomies.
== 戻り値 ==
+
</div>
+
  
; (array|bool) :  取得できない場合は<tt>false</tt>。成功した場合はタームオブジェクトからなる配列。
+
== Usage ==
 +
<?php get_term( $term, $taxonomy, $output, $filter ) ?>
  
<div id="Example">
+
== Parameters ==
== 例 ==
+
{{Parameter|$term|integer&#124;object|If integer, will get from database. If object will apply filters and return <tt>$term</tt>.}}
</div>
+
{{Parameter|$taxonomy|string|Taxonomy name that <tt>$term</tt> is part of.}}
 +
{{Parameter|$output|string|Constant OBJECT, ARRAY_A, or ARRAY_N|optional|OBJECT}}
 +
{{Parameter|$filter|string|default is raw or no WordPress defined filter will applied.|optional|'raw'}}
  
<div id="A_Basic_Example">
+
== Return Values ==
=== 基本的な例 ===
+
; (mixed&#124;null&#124;WP_Error) : Term Row from database. Will return null if <tt>$term</tt> is empty. If taxonomy does not exist then <tt>[[クラスリファレンス/WP_Error | WP_Error]]</tt> will be returned.
</div>
+
  
<div id="Notes">
+
== Examples ==
== 注意点 ==
+
<!-- Need creative examples. Feel free to link to external examples. -->
</div>
+
Get Term offers some handy information, but unfortunately lacks a link value.
  
結果を取得するために<tt>get_object_term_cache()</tt>か<tt>wp_get_object_terms()</tt>を使います。
+
<code>$term = get_term( $term_id, $taxonomy );</code>  
  
<div id="Change_Log">
+
Gives you term slug: e.g.: term-slug-example
== 改訂履歴 ==
+
</div>
+
  
* Since: [[Version 2.5|2.5.0]]
+
<code>$slug = $term->slug;</code>
  
<div id="Source File">
+
Gives you term name: e.g. Term Name Example
== ソースファイル ==
+
</div>
+
  
<tt>get_the_terms()</tt>は<tt>wp-includes/category-template.php</tt>にあります。
+
<code>$name = $term->name;</code>
  
<div id="Related ">
+
Gives you term description: e.g. This is my new cool custom term.
== 関連項目 ==
+
</div>
+
[[関数リファレンス/get_the_term_list|get_the_term_list()]],
+
[[関数リファレンス/wp_get_object_terms|wp_get_object_terms()]]
+
  
 +
<code>$desc = $term->description;</code>
  
[[Category:関数リファレンス]]
+
== Notes ==
 +
* See [[関数リファレンス/sanitize_term_field|<tt>sanitize_term_field()</tt>]] The <tt>$context</tt> param lists the available values for [[関数リファレンス/get_term_by|<tt>get_term_by()</tt>]] <tt>$filter</tt> param.
 +
* Uses: [[関数リファレンス/sanitize_term|<tt>sanitize_term()</tt>]] Cleanses the term based on <tt>$filter</tt> context before returning.
 +
* Uses global: (<tt>object</tt>) [[クラスリファレンス/wpdb|<tt>$wpdb</tt>]]
 +
 
 +
== Change Log ==
 +
Since: 2.3.0
 +
 
 +
== Source File ==
 +
<!-- Need links to current source code files -->
 +
<tt>&get_term()</tt> is located in {{Trac|wp-includes/taxonomy.php}}.
 +
 
 +
== Related ==
 +
{{Term Tags}}
 +
 
 +
{{Tag Footer}}
 +
 
 +
{{原文|Function Reference/get term|137896}} <!-- 19:41, 9 November 2013 Jdgrimes 版 -->
 +
 
 +
{{DEFAULTSORT:Get_term}}
 +
[[Category:関数]]
 +
 
 +
[[en:Function Reference/get term]]

2014年7月30日 (水) 18:42時点における版

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

Description

Get all Term data from database by Term ID. To retrieve term data by name, slug or ID, use get_term_by() instead

The usage of the get_term function is to apply filters to a term object. It is possible to get a term object from the database before applying the filters.

$term ID must be part of $taxonomy, to get from the database. Failure, might be able to be captured by the hooks. Failure would be the same value as $wpdb returns for the get_row method.

There are two hooks, one is specifically for each term, named 'get_term', and the second is for the taxonomy name, 'term_$taxonomy'. Both hooks gets the term object, and the taxonomy name as parameters. Both hooks are expected to return a Term object.

'get_term' hook - Takes two parameters the term Object and the taxonomy name. Must return term object. Used in get_term() as a catch-all filter for every $term.

'get_$taxonomy' hook - Takes two parameters the term Object and the taxonomy name. Must return term object. $taxonomy will be the taxonomy name, so for example, if 'category', it would be 'get_category' as the filter name. Useful for custom taxonomies or plugging into default taxonomies.

Usage

<?php get_term( $term, $taxonomy, $output, $filter ) ?>

Parameters

$term
integer|object) (必須) If integer, will get from database. If object will apply filters and return $term.
初期値: なし
$taxonomy
string) (必須) Taxonomy name that $term is part of.
初期値: なし
$output
string) (optional) Constant OBJECT, ARRAY_A, or ARRAY_N
初期値: OBJECT
$filter
string) (optional) default is raw or no WordPress defined filter will applied.
初期値: 'raw'

Return Values

(mixed|null|WP_Error) 
Term Row from database. Will return null if $term is empty. If taxonomy does not exist then WP_Error will be returned.

Examples

Get Term offers some handy information, but unfortunately lacks a link value.

$term = get_term( $term_id, $taxonomy );

Gives you term slug: e.g.: term-slug-example

$slug = $term->slug;

Gives you term name: e.g. Term Name Example

$name = $term->name;

Gives you term description: e.g. This is my new cool custom term.

$desc = $term->description;

Notes

Change Log

Since: 2.3.0

Source File

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

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 term最新版との差分