Home Forums ACF PRO Building fields and pulling data to the front


Building fields and pulling data to the front

  • 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!

  • It is hard to say what is best.

    I build the admin/fields interface in what I believe makes it most usable by the client, then I deal with the coding necessary to use them, but then I don’t depend on code in the documentation except as basic examples.

  • OK, if this way is fine and doesn’t affect the performance of the site or anything else I guess that’s all I wanted to know. Thank you John!

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.