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' ) ) {
return;
}
// This function may be called directly from template functions. Bail early if already did this.
if ( acf_did( 'init' ) ) {
return;
}
...
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.