Hi,
I would like to know from more specialized people if the way I am pulling the data from the ACF fields is okay and does not affect the performance of the site. Maybe in general whether it is correct or not.
So would it be a good approach to use get_fields()
? I assign this function to the $fields
variable and it opens up the possibility for me to reach almost any field created in the plugin.
For example, I have a group created and a repeater in it. Would the correct approach be to nest like this and reach the selected field like this?
foreach($fields['group']['repeater'] as $repeater) {
echo $repeater['first-repeater-field'];
}
Or is it better to avoid such nesting? I’ll admit that group division is quite convenient and the maximum nesting level is 2, sometimes 3-4 and if the structure of the page is complicated then maybe 5 levels.
On the other hand, I have encountered a statement to avoid the group field and make everything as shallow as possible. Then I can copy snippets from ACF documentation and that is the best way. However, it limits me some ways to build fields, but if this is better, more correct and more efficient, then I need to change my approach.
Or is it completely irrelevant and both approaches are totally fine?
Thanks in advance for your help!