I’ve build some page layout stuff using ACF flex fields. Honestly, I don’t think there is an “easy” way when you need the information that’s stored in the layout fields to determine html, classes or css values before you can display anything. There are really 2 choices 1) loop through the fields twice, once do determine layout and once for the data 2) loop thought the fields once and store the data to use as your building the layout. Of the 2 I would do the second only because it means not repeating myself.
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!
The ACF site is currently experiencing some issues.— Advanced Custom Fields (@wp_acf) September 29, 2022
We apologize for the inconvenience and we are working hard to get it back up and running as soon as possible.
© 2022 Advanced Custom Fields.