I’m having trouble with my custom WordPress theme. After updating to the newest WordPress version, the site crashes with a 500 Error. The error log shows this:
PHP Fatal error: Cannot redeclare is_iterable() (previously declared in
wp-includes/compat.php:536) in
wp-content/themes/mytheme/custom_functions.php on line 40
I’m not great with PHP and I’ve heard our code might be old. We’re using PHP 7.0 right now.
The problem seems to be in our custom_functions.php file. It has this function:
function check_if_loopable($item) {
return (is_array($item) || $item instanceof Traversable);
}
Any ideas on how to fix this? I’m not sure why the update broke our theme or how to make it work again. Help would be great!
sounds like ur using an old php version mate. wp 6.0+ needs php 7.4 minimum. try upgrading ur php to 7.4 or higher. also, rename that function in ur custom_functions.php to something unique like ‘my_check_if_loopable’. that should fix the conflict with wp’s built-in function. good luck!
I’ve encountered similar issues in the past and believe that compatibility can often be the culprit. In this case, the error you see arises from a function name conflict due to differences between older PHP versions and the newest WordPress update. It might be wise to upgrade your PHP version to at least 7.4 or even consider PHP 8.0 if your system supports it. Additionally, renaming your custom function to something more specific to your theme—using a unique prefix—should help avoid conflicts with WordPress’s built-in functions. It’s always a good idea to create a backup of your site before making such changes and to run thorough tests afterwards.
In my experience, core updates to WordPress can reveal legacy issues that may not be obvious until a conflict arises with custom code. The error here is due to a redeclared function, which conflicts with WordPress core functions. I recommend upgrading your PHP version to at least 7.4 to ensure improved compatibility with the latest WordPress standards.
Additionally, renaming the conflicting custom function to something unique, such as mytheme_check_if_loopable, should prevent further issues. Always back up your site before making changes and test thoroughly after making adjustments.