Advanced Custom Fields

Error with Advanced Custom Fields

You may have this kind of error with Advanced Custom Fields :

Fatal error: Uncaught Error: Call to a member function init() on array in /wp-content/plugins/advanced-custom-fields/includes/api/api-helpers.php:209

Stack trace:
#0 /wp-content/plugins/advanced-custom-fields/includes/api/api-template.php(310): acf_init()
#1 /wp-content/plugins/advanced-custom-fields/includes/api/api-template.php(269): get_field_objects(85, true)
#2 /wp-content/themes/fwrhs/index.php(77): get_fields(85)
#3 /wp-includes/template-loader.php(106): include(‘/var/www/vhosts…’)
#4 /wp-blog-header.php(19): require_once(‘/var/www/vhosts…’)
#5 /www in /wp-content/plugins/advanced-custom-fields/includes/api/api-helpers.php on line 209

Or :

Recoverable fatal error: Object of class WP_Term could not be converted to string in /wp-content/plugins/advanced-custom-fields/includes/api/api-template.php on line 89

Or :

Fatal error: Uncaught ArgumentCountError: Too few arguments to function sp_acfe_flexible_enqueue(), 2 passed in /wp-includes/class-wp-hook.php on line 303 and exactly 3 expected in /wp-content/mu-plugins/modified_vendor_hooks.php:105 Stack trace: #0 /wp-includes/class-wp-hook.php(303): sp_acfe_flexible_enqueue(Array, true) #1 //wp-includes/class-wp-hook.php(327): WP_Hook->apply_filters('', Array) #2 /wp-includes/plugin.php(470): WP_Hook->do_action(Array) #3 /wp-content/plugins/acf-extended/includes/fields/field-flexible-content-preview.php(227): do_action('acfe/flexible/e...', Array, true) #4 /wp-includes/class-wp-hook.php(303): acfe_field_flexible_content_preview->render_field(A in /wp-content/mu-plugins/modified_vendor_hooks.php on line 105

Or :

Uncaught Error: Call to undefined function get_current_screen() in /wp-content/plugins/acf-archive/acf-archive.php:102

Or :

Deprecated: Required parameter $field follows optional parameter $post_id in /wp-content/plugins/advanced-custom-fields/includes/acf-value-functions.php on line 54

Deprecated: Required parameter $field follows optional parameter $value in /wp-content/plugins/advanced-custom-fields/includes/acf-value-functions.php on line 166

Deprecated: Required parameter $value follows optional parameter $key in /wp-content/plugins/advanced-custom-fields/includes/ajax/class-acf-ajax.php on line 76

Or :

Fatal error: Uncaught Error: Call to a member function init() on array in /wp-content/plugins/advanced-custom-fields/includes/api/api-helpers.php:209

Stack trace:
#0 /wp-content/plugins/advanced-custom-fields/includes/api/api-template.php(310): acf_init()
#1 /wp-content/plugins/advanced-custom-fields/includes/api/api-template.php(269): get_field_objects(85, true)
#2 /wp-content/themes/fwrhs/index.php(77): get_fields(85)
#3 /wp-includes/template-loader.php(106): include(‘/var/www/vhosts…’)
#4 /wp-blog-header.php(19): require_once(‘/var/www/vhosts…’)
#5 /ww in /wp-content/plugins/advanced-custom-fields/includes/api/api-helpers.php on line 209

Or :

PHP Notice: acf_get_value was called incorrectly. We’ve detected one or more calls to retrieve ACF field values before ACF has been initialized. This is not supported and can result in malformed or missing data.

Or :

Deprecated: Required parameter $field follows optional parameter $value in /wp-content/plugins/advanced-custom-fields-pro/includes/acf-value-functions.php on line 164

Or :

Fatal error: Uncaught Error: Call to a member function init() on array in /wp-content/plugins/advanced-custom-fields/includes/api/api-helpers.php:209

Stack trace:
#0 /wp-content/plugins/advanced-custom-fields/includes/api/api-template.php(310): acf_init()
#1 /wp-content/plugins/advanced-custom-fields/includes/api/api-template.php(269): get_field_objects(85, true)
#2 /wp-content/themes/fwrhs/index.php(77): get_fields(85)
#3 /wp-includes/template-loader.php(106): include(‘/var/www/’)
#4 /wp-blog-header.php(19): require_once(‘/var/www/’)
#5 /var/ww in /wp-content/plugins/advanced-custom-fields/includes/api/api-helpers.php on line 209

There are multiple solutions to try to make it work.

Updates

The first thing to do if you are stuck with Advanced Custom Fields is to ensure that all your WordPress is up to date. You should check your :

  • WordPress
  • Plugins
  • Theme

Once all these updates are done, check back if these errors appear.

Check Advanced Custom Fields

Sometimes, you just need to disable the plugin, and enable it just after to make it work again.

If it doesn’t work, your Advanced Custom Fields plugin may be corrupted. To ensure that it’s not your case, you have to re-download the plugin (or the theme delivered with the plugin) and try to install it again.

Check others plugins

Are you sure that the error is related to Advanced Custom Fields? Maybe not.

It could be related to another plugin that is not compatible. It could happen when you use a cache plugin, a security plugin, or simply a poorly developed plugin.

Disable all plugins. Then, check for your error, if the error is still there, the problem is not related to plugins compatibility. If there are no more errors, then enable every plugin one by one and check for the error. The goal is to target the plugin involved.

Try another theme

The error can be a problem with your theme.

If it’s not already done, then you should install & activate the default WordPress theme like Twenty Twenty-Two. Check for the error, and see what is happening to be sure that your WordPress theme is not the cause.

Permalinks & htaccess

If it doesn’t work, you may have a problem with your WordPress permalinks and/or your htaccess file. You should go on your WordPress dashboard, and re-saving permalinks from the permalinks page.

Contact the developer

If all these solutions don’t work, we advise you to contact the plugin developer.

You may have found a new bug, or a specific issue. You should get in touch with the developer either on the WordPress plugin forum, either by mail, either on their specific website with their own support.

Alternative solutions

If the developer doesn’t reply, or your problem is very urgent, then you should try an alternative to the plugin.

There are thousands of plugins on the official directory, and many others outside. You should try to find and test them!

If the issue is very specific, and the plugin could not be replaced, we advise you to contact an expert.
This is the best way to ensure you're not going to break your site anymore.