You could use multiple fields, probably in a repeater, where you supply all the information. For example a “URL” field, a link “Text” field and an field to enter the icon you want to use.
Yes, I thought about that but I don’t want/need to input new information every time I create a post. The choices and their values should be pre-defined. Every time I choose “WordPress”, for instance, it should show the WordPress Icon followed by the word WordPress as a link on the front end. I can’t do that with the repeater field, can I?
You could also code the icons and url into your template based on the values selected, but your code would need to supply the icon and the url information.
That would be ideal and is basically what I’m looking for. But how can I achieve this? Since the checkbox field only provides one value per choice, I would have to find a way to check if that value matches a certain string and if so, prepend the code for the icon and wrap the value into the right link tag. I’m sure this would be possible with PHP, but I’m not that good at it and I’m pretty sure that it would lead to very long code in the template, right?
If I would just have the option to assign the three variables icon word, url, and name to each choice and if it would provide those three values separately instead of just as one single value, then I would be comfortable to do the rest in the template.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
ACF PRO’s Flexible Content field allows you to create smaller pieces of UI and compose them into whole flexible patterns. In our latest article, we show how to use it to create swappable site sections and integrate it all in a theme.https://t.co/ZRocH8oJSp— Advanced Custom Fields (@wp_acf) January 24, 2023
© 2023 Advanced Custom Fields.