私は常にタクソノミーを嫌い、とても混乱しています。私はACFを使用しています。私はカスタムユーザー登録フィールドの国、コンセント、会社(彼らはすべての分類法です)を呼び出しています。Wordpress - 用語ID(ACF)からタクソミーム名の名前を取得
例:分類=国& TAG_ID = 36 & post_type =会社
$country_tagid = the_field('country', 'user_'.$user_id->ID); //This output 36
$countrydata = get_terms('country',array('id'=>$country_tagid)); //
echo $countrydata->name; //return nothing
$getcountrydata = get_term($country_tagid);
print ($getcountrydata->name); //return nothing
それらのすべては、名前を返しませんでした。私はそれが「タイ」を返すと期待しています。なにが問題ですか?
編集: 奇妙なことに、私は手動でユーザーのループの外側に入力しました。
<?php
$catinfo = get_term_by('id', 36, 'country');
print $catinfo->slug; //thailand
?>
これは機能します。 私は
$country_tagid = the_field('country', 'user_'.$user_id->ID); //This output 36
ここで何かが間違っている疑いがあるこの行は36が今、私はget_fieldしようとしている印刷します。しかし、それはこれを試して
$ countrydata = get_terms」をcountry '、array(' include '=>配列($ country_tagid))); print_r($ countrydata); Array()を返します。 –