[英]What would the TWIG equivalent of <?php the_field('field_name'); ?> be?
我正在将Wordpress与“高级自定义字段”插件一起使用 ,并且试图将插件中的变量调用到TWIG文件中。
该插件的文档说要使用<?php the_field('field_name'); ?>
<?php the_field('field_name'); ?>
在PHP中,但我不知道如何将代码转换为TWIG。
我尝试了以下方法:
{% post.the_field('my_fields_name') %}
,但无济于事 {{ post.my_fields_name }}
,但它在前端打印/记录了“数组”。 {{ post.get_field('the_field', my_fields_name) }}
和{{ post.get_field('the_field', 'my_fields_name') }}
任何帮助将不胜感激
花了我一段时间,但最终成为一个简单的解决方案! 原来这些自定义字段存储在元数据中,所以我要做的就是{{ post.meta('my_fields_name') }}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.