Support

Account

Home Forums General Issues ACF/INIT in combination with get_fields in functions.php

Helping

ACF/INIT in combination with get_fields in functions.php

  • Hello there,

    I have the following problem:

    I use PHP to render groups and fields in a theme. To add the fields I use the acf/init action: https://www.advancedcustomfields.com/resources/acfinit/

    In functions.php and other backend files I want to call the get_fields(‘options’); to call all registrated fields.

    This is only not working. But in the header.php it is working.

    I’ve also tried to call the action on the wordpress init. But this gives the same result.

    My question. Is there a way to register custom fields by PHP and use get_fields(‘options’) to get all the registrated custom fields through PHP?

  • Not sure I completely understand. Are you trying to get values for fields that have not had anything saved to them yet?

    If you are creating field groups on some specific hook then you can’t get the values for those fields until after the field groups are created and get_fields() will not return fields that have not been saved yet.

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

You must be logged in to reply to this topic.