function getWidgets($position = null) {
if (empty($this->widgets)) {
foreach (wp_get_sidebars_widgets() as $pos => $ids) {
$this->widgets[$pos] = array();
foreach ($ids as $id) { // error is here
$this->widgets[$pos][$id] = $this->getWidget($id);
}
}
}
}
这些是第305-314行。
我收到了这个错误:
" Warning: Invalid argument supplied for foreach() in /home/content/73/9889573/html/wp-content/themes/yoo_spark_wp/warp/systems/wordpress.3.0/helpers/system.php on line 310 "
有人可以告诉我如何解决它
答案 0 :(得分:2)
wp_get_sidebars_widgets()
返回一维数组。
参考:http://codex.wordpress.org/Function_Reference/wp_get_sidebars_widgets
$ids
不是数组。您无法在foreach
循环中遍历它。
试试这个:
$widgets = array();
foreach (wp_get_sidebars_widgets() as $pos => $id) {
$widgets[$pos] = $this->getWidget($id);
}