【发布时间】:2017-09-20 11:08:46
【问题描述】:
我一直讨厌分类学,它太混乱了。我正在使用 ACF。我有一个自定义用户注册字段调用国家、出口、公司(它们都是分类法)。
例如。 taxonomy=country&tag_ID=36&post_type=company
$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。但它返回给我 arr
【问题讨论】:
标签: wordpress categories advanced-custom-fields taxonomy term