Hi,
I have created a Custom Post Type with ACF as well as two taxonomies (category and type) for the same CPT.
I try to use TWIG for the following tasks:
-
I want the tile background color for each post in the archive to match its custom post type category. I have three categories and want to have three different colors. I use the following code. When I utilize a text element, the color codes are displayed correctly. However, if you use this code on the background field it doesn’t work.
{% if acf.post_field({"field":"category"}) == 36 %} global-color:lkgMQvt4yhqVR2Qq3o {% elseif acf.post_field({"field":"category"}) == 37 %} global-color:w9CI4DQGHT2WfP2gBf {% else %} global-color:tmjfa017L2LYJoWru8 {% endif %}
The scenario with Icon Element mirrors this closely. If I put the following code inside a Text Element I see the icons names as they were planed. But as soon as I put it inside the Icon Element in breakout mode it doesn’t show any icons.
{% if acf.post_field({"field":"type"}) == 20 %}
volleyball
{% elseif acf.post_field({"field":"type"}) == 21 %}
volleyball
{% elseif acf.post_field({"field":"type"}) == 22 %}
futbol
{% elseif acf.post_field({"field":"type"}) == 23 %}
microphone-lines
{% elseif acf.post_field({"field":"type"}) == 24 %}
eye
{% elseif acf.post_field({"field":"type"}) == 25 %}
chart-pie
{% elseif acf.post_field({"field":"type"}) == 26 %}
user-group-simple
{% elseif acf.post_field({"field":"type"}) == 27 %}
earth-europe
{% elseif acf.post_field({"field":"type"}) == 35 %}
bags-shopping
{% else %}
circle-o
{% endif %}
What is wrong, please suggest.