2

I am receiving the following warning:

Warning: reset() expects parameter 1 to be array, null given in /data/9/1/115/118/1767118/user/1910351/htdocs/aw/home/wp-content/themes/awthemesnew/library/sidebars.php on line 183

Keep in mind I am editing a wordpress .php file. Here is the full code on line 183:

function theme_print_sidebar($name, $places) {
    $style = theme_get_option('theme_sidebars_style_' . $name);
    $place_count = count($places);
    if ($name != 'footer' && $place_count < 2) {
        theme_print_widgets(reset($places), $style);
        return;
    }
    ?>

Help. Thanks!

2 Answers 2

2

The value of $places is apparently null by the time you call reset.

Your code is saying "only call reset when the value of $place_count is less than 2". You're setting the value of $place_count via the statement:

$place_count = count($places);

We can infer that when count() is called on a null variable it returns 0. Since 0 is less than 2, the following statement is executed:

    theme_print_widgets(reset($places), $style);

However, at this point the fact that $places is null is causing an error. I would be curious to know under what circumstances $places is null. Once you've got the answer to that you can decide how to handle that case.

Sign up to request clarification or add additional context in comments.

1 Comment

Here is the page the error is happening on: aromaticwaters.com/home/product-category/diffusers
0

I figured it out. I had erased a command in the footer and when the code when looking for it, since it was gone, it gave me a array warning. Thanks for the help.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.