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

関数リファレンス/get term

提供: WordPress Codex 日本語版
< 関数リファレンス
2014年7月30日 (水) 18:42時点におけるGblsm (トーク | 投稿記録)による版 (en:Function Reference/get term 19:41, 9 November 2013 Jdgrimes 版を流し込み。)

移動先: 案内検索

このページ「関数リファレンス/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最新版との差分