Support

Account

Home Forums ACF PRO Run repeater loop 2x (get classes for styles) – good technique? Reply To: Run repeater loop 2x (get classes for styles) – good technique?

  • I don’t see any issues with what you’re doing. It should not slow things down because any data you get from the first loop through should be cached.

    I have debated this as well and I’ve just started adding styles directly into the page, the ugly method you mentioned. Will it be supported in the future? Browsers rarely remove support for things because it would mean breaking thousands of sites. They still support framesets. As far as ugly… well, I like to be able to edit all of the code for me flex layouts in a single template part file, my concern is more about how much work it is to change over what the HTML looks like.

    On the other hand, for something like you’re doing I created a button builder on an options page. In the button builder I give each button a unique ID. I then use this ID as a class identifier and output the css for these classes in the head. In the flex field I build a UI that allows the editor to chose one of the pre-built button types and I just insert the correct class name into the html.