My theme relies pretty heavily on ACF, and every time I update the plugin, I get “Call to undefined function get_field()” errors, so I have to go rename my theme directory, activate the newly updated ACF, then restore my theme directory name.
I could go in & add if(function_exists('get_field'))
all over the place, but it seems like this didn’t used to happen, so I’m a bit stumped.
I don’t usually work custom fields into admin hooks very often, so I would imagine that this is only happening to get_field()
calls that exist in admin-side hooks (pre_get_posts
for an example). Also not really familiar with how the plugin update process works, but I do know that the plugin folder is cleaned out and the new plugin is extracted, so the errors are probably firing somewhere between those two events.
Solution? No idea. Maybe just do your function_exists
checks on the hooks and filters that apply to admin-side functions…
I’m having this issue as well, I recently installed Types after working on a Theme. The Theme does not seem to be loading whatever includes it needs to be to get the Types API.
Fatal error: Call to undefined function get_field() in /home/eitsllcwp/public_html/wp-content/themes/linen_pro/tm-customers.php on line 35
Hi @AmandaB
Any calls to get_field
(or any other ACF functions) within your functions.php must be wrapped in a function_exists
statement.
This is because the functions.php file is read during the update while ACF is unavailable.
Thanks
E