ACF Not Retrieving Values in a Plugin

Hello,

I’m developing a plugin, and when I use a simple get_field('name_input', 'options');, the value is “null” and returns nothing. In theme it’s good.

Do you have any ideas to resolve this issue? Do I need to add something to ensure that all my back-office records are taken into account?

I’m working with Sage 10 and Bedrock. I’m using the latest version of ACF and the latest version of WordPress.

Note : It’s multiste.

Thank you in advance! Mathieu

ACF functions rely on some ACF hooks triggering before they’re executed. If you use an ACF function too early, those hooks haven’t triggered and instead of failing loudly the method does what you’re seeing. You could:

  • call that function later in the load order
  • get your data via WP core functions instead of ACF’s, ie get_option()
1 Like

In addition to the reply above. It may simply be that your code is using options instead of option which it should be.

1 Like

Not that it helps the OP but both ”option” and ”options” are supported :slight_smile: ACF | Get values from an options page

Ah fair point missed it saying both can be used. Thanks for confirming :+1:

1 Like