term_exists

Sponsored Link

取得したタームが存在するかどうかを確認し、タームIDを返します。タームが存在しない場合は、タームオブジェクトあるいは0(false)を返します。

Sponsored Link

Check if a given term exists and return the term ID, a term object, or 0 (false) if the term doesn’t exist.

term_existsのファンクションタグ使用方法

<?php term_exists( $term, $taxonomy, $parent ) ?>

term_existsのパラメーター

$term

(integer|string) (required)チェックするためのターム。
デフォルト;なし

(integer|string) (required) The term to check
Default: None

$taxonomy

(string) (optional)使用するためのタクソノミー名
デフォルト:”

(string) (optional) The taxonomy name to use
Default: ”

$parent

(integer|string) (optional)存在する検索を限定するための親ターム上の$parentのID。
Default: ”

(integer|string) (optional) $parent ID of parent term under which to confine the exists search
Default: ”

戻り値

(mixed)

  • タームが存在しない場合は0を返します。
  • タクソノミーが指定されていない場合タームIDを返して、タームは存在します。
  • ペアが存在する場合は配列を返します。(フォーマット:array(‘term_id’=>term id, ‘term_taxonomy_id’=>taxonomy id))
  • Returns 0 if the term does not exist.
  • Returns the term ID if no taxonomy was specified and the term exists.
  • Returns an array if the pairing exists. (format: array(‘term_id’=>term id, ‘term_taxonomy_id’=>taxonomy id))

‘未分類’カテゴリーが存在するかどうかを確認します

<?php
$term = term_exists('Uncategorized', 'category');
if ($term !== 0 &amp;&amp; $term !== null) {
  echo "'Uncategorized' category exists!";
}
?>

注意

Uses global: (object) $wpdb

変更ログ

Since: 3.0

ソースファイル

term_exists()は、wp-includes/taxonomy.php内に位置しています。

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

関連ファンクションタグ

Conditional Tags: comments_open(), is_404(), is_admin(), is_admin_bar_showing(), is_archive(), is_attachment(), is_author(), is_category(), is_comments_popup(), is_date(), is_day(), is_feed(), is_front_page(), is_home(), is_local_attachment(), is_multi_author, is_month(), is_new_day(), is_page(), is_page_template(), is_paged(), is_plugin_active(), is_plugin_active_for_network(), is_plugin_inactive(), is_plugin_page(), is_post_type_archive(), is_preview(), is_search(), is_single(), is_singular(), is_sticky(), is_tag(), is_tax(), is_taxonomy_hierarchical(), is_time(), is_trackback(), is_year(), in_category(), in_the_loop(), is_active_sidebar(), is_active_widget(), is_blog_installed(), is_rtl(), is_dynamic_sidebar(), is_user_logged_in(), has_excerpt(), has_post_thumbnail(), has_tag(), pings_open(), email exists(), post_type_exists(), taxonomy_exists(), term_exists(), username exists(), wp_attachment_is_image(), wp_script_is()

Terms: 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(), wp_get_object_terms(), wp_set_object_terms(), wp_get_post_terms(), wp_set_post_terms()

Sponsored Link