get_terms()

投稿日:2022-08-10 投稿者:PS カテゴリ:その他 タグ: , , , ,

カテゴリーやタグの情報を取得する。

書式

<?php // 書式
$terms = get_terms($taxonomies, $args);
// 例
$tags = get_terms("post_tag");   // 登録されているタグの情報を配列で取得

$taxonomies

“categories”カテゴリー
“post_tag”タグ
“link_category”
“post_format”投稿フォーマット?

$args

引数名初期値選択肢など
orderbystringnameid, count, name, slug, term_grp, none
orderstringASCASC, DESC
hide_emptyboolean11(true), 0(false)
excludeint.string,array除外するタームID。
exclude_treeint除外する親タームの ID。
parentint直近の子タームを返す(指定された値が親タームの ID であるタームのみ)。
0 を指定すると、トップレベルのタームのみを返す。

参照