Home Forums General Issues get_field returning null after update Reply To: get_field returning null after update

  • @cbrady23 if the get_field() call is not in a “plugins_loaded” action, when is it called?

    By when I specifically mean is it called before or after the acf/init action is fired.

    Basically, no acf function should be called before the acf/init action fires. This happens on the WP “init” action at a priority of 5. Calling any ACF function before this time will cause unexpected results. Even the “plugins_loaded” function is really too soon. In some cases calling an ACF function too early causes what I call premature initialization. What I mean by that is that ACF looks to see if it has been initialized by looking to see if the acf/init function has been fired [did_action()] and if the action has not been done ACF calls its initialization routine and ACF will not initialize before the ‘plugins_loaded’ hook

    function init() {
      // Bail early if called directly from functions.php or plugin file.
      if ( ! did_action( 'plugins_loaded' ) ) {
      // This function may be called directly from template functions. Bail early if already did this.
      if ( acf_did( 'init' ) ) {