[英]To get meta field (ACF) in taxonomy template
我在分类页面中,在自定义分类和特定术语的URL中:
http://localhost:3000/personas/cristina-aiken-soux/
另外,我对此页面有一个分类模板:
taxonomy-personas.php
在此模板中,我试图恢复并显示“高级自定义字段”:
$term_object = get_queried_object();
the_field('picture', $term_object->term_id);
但是nothig返回了。 为什么?
如果我做print_r($term_object);
我可以看到查询的对象:
WP_Term Object (
[term_id] => 2 [name] => Cristina Aiken Soux
[slug] => cristina-aiken-soux
[term_group] => 0
[term_taxonomy_id] => 2
[taxonomy] => personas
[description] => Cras in elementum enim, vitae volutpat sapien. Duis at sem in quam ultrices hendrerit. Class aptent taciti sociosqu ad litora torquent.
[parent] => 0
[count] => 2
[filter] => raw
)
那么,为什么我不能恢复de ACF?
谢谢!
最后,我找到了解决方案
$foto = get_field('fotopersona', 'personas'.'_'.$term_object->term_id);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.