简体   繁体   中英

Updating WordPress Breaks custom Wordpress theme

We have a custom developed theme that gets broken with a 500 Error when updating to the latest WordPress.

I am receiving this error in the log file:

PHP Fatal error: Cannot redeclare is_iterable() (previously declared in 
/home/smartservice/dev.smartservice.com/wp-includes/compat.php:536) in 
/home/smartservice/dev.smartservice.com/wp- 
content/themes/smartservice/custom_functions.php on line 40

I'm unfamiliar with Php to this extent and i've heard it's outdated. We are running PHP 7.0 on the current site that this error is on.

The code for these lines are - custom-function.php compact.php

function is_iterable ( $var ) {
return ( is_array($var) || $var instanceof Traversable );
}

By below code it will clear this error.

if(!function_exists('is_iterable'){
    function is_iterable ( $var ) {
        return ( is_array($var) || $var instanceof Traversable );
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM