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!
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:
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:
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.
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.