WordPress on PHP 8: Fatal error: Uncaught Error: Call to undefined function create_function() / each()
An old plugin/theme uses functions removed in PHP 8 (create_function, each), so the site breaks after a PHP upgrade.
Seen on:
WordPress
Meaning
create_function and each() were deprecated in PHP 7.2 and removed in 8.0. Abandoned plugins/themes crash on modern hosting. Update or replace them; patching uses closures/foreach.
Common causes
- Outdated plugin/theme with PHP 5-era code
- Host upgraded PHP to 8.x
- Custom code in functions.php
⚡ Quick fix
- Update the plugin/theme or replace it
- Temporarily switch PHP back while you fix it
- Rewrite create_function as an anonymous function
Detailed fix by platform
PHP
- php
// old: add_action('widgets_init', create_function('', 'return register_widget("My_Widget");')); add_action('widgets_init', function () { register_widget('My_Widget'); });
How to diagnose
- File — Which plugin/theme?
- PHP — Version upgrade recently?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Call to undefined function PHP Fatal error: Uncaught Error: Call to undefined function
- Call to undefined function (WordPress) WordPress: Fatal error: Uncaught Error: Call to undefined function wp_get_current_user() / add_action() / get_header()
- cookies() should be awaited Next.js 15: Route "/x" used `cookies().get('token')`. `cookies()` should be awaited before using its value
Most viewed in WordPress
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026