Problem: I have a custom text field that is used to store the name of a country. I would like to display the flag of that country on the front-end of the site, instead of the text name of the country.
Solution: You can construct an image HTML tag using the Types field shortcode as a variable. For example, you can upload images like "Tanzania.jpg" and "Rwanda.jpg" to your server, then build the image tag like this:
<img src="/wp-content/uploads/flags/[types field='country' output='raw'][/types].jpg" alt="[types field='country' output='raw'][/types]" />
It only works if the country names and image file names are identical. If possible, you should use a select field with predefined country names.
Relevant Documentation:
https://toolset.com/documentation/customizing-sites-using-php/functions/
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 5 years, 9 months ago.
Assisted by: Christian Cox.