简体   繁体   中英

Warning: Trying to access array offset on value of type bool in C:\xampp\htdocs\wordpress2\wp-content\themes\sport-ak\framework

Warning: Trying to access array offset on value of type bool

Warning: Trying to access array offset on value of type bool in C:\xampp\htdocs\wordpress2\wp-content\themes\sport-ak\framework\class.category-custom-fields.php on line 133

And here's the line 133:

return isset($key)? $cat_meta[$key]: '';

This is the full one:

public function get_category_meta($term_id, $key) {
        if (!$term_id)
            return;

        $cat_meta = get_option("category_$term_id");

        return isset($key) ? $cat_meta[$key] : '';

Line 133 is checking if variable $key is existing, and if it is, it tries to return something from a different variable: $cat_meta .

You should check if variable $cat_meta[$key] exists, like this:

return isset($cat_meta[$key]) ? $cat_meta[$key] : '';

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