Hi,
I am pretty new to WordPress and ACF so please bear with me )
I have created a custom, theme with some templates.
In the admin I have used ACF to create some custom field e.g. left_text
and right_text
, and I have set the value for those fields in a post I created.
Then in the template I use <!-- wp:acf/left_text -->
but it does not output the value for left_text
any ideas what am I doing wrong?
Greetings,
Ilian
What do you mean by “template”? You cannot use tags like <!-- wp:acf/left_text -->
in a php template.
https://www.advancedcustomfields.com/resources/displaying-custom-field-values-in-your-theme/
Hi John,
sorry maybe I failed to explain correctly.
I have a block theme, and in the templates/single.html
file I have added the <!-- wp:acf/left_text -->
tag.
Other tags e.g. <!-- wp:post-title /-->
work correctly there and produce output.
P.S. If I use a php template instead e.g. single.php
at the root directory of the template <?php the_field('left_text'); ?>
produces the desired output, which confirms that the field name is correct.
It is just that I want to show it in the HTML template.
Thank you very much for you help )
the tags you are referencing are processed by WP when it gets the content from the WP editor. I have no idea how these tags are processed in the PHP template or how to include acf fields in this manor.
I see, do you know by any chance which method the <!-- wp:acf/left_text -->
calls? I can try to debug it myself if I know what it calls.