I'm using Wordpress with the "Advanced Custom Fields" plugin , and I'm trying to call variables from the plugin into my TWIG file.
The documentation for the plugin says to use <?php the_field('field_name'); ?>
<?php the_field('field_name'); ?>
in the PHP, but I can't figure out how to translate that code to TWIG.
I tried the following:
{% post.the_field('my_fields_name') %}
, but to no avail {{ post.my_fields_name }}
, but it printed/logged "Array" to the frontend. {{ post.get_field('the_field', my_fields_name) }}
and {{ post.get_field('the_field', 'my_fields_name') }}
Any help will be greatly appreciated
Took me a while, but ended up being an easy solution! Turns out these custom fields are stored in the meta-data, so all I had to do was {{ post.meta('my_fields_name') }}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.