Php 使用wordpress wp_get_边栏_widgets()时发生foreach()错误
这些是第305-314行 我得到了这个错误:Php 使用wordpress wp_get_边栏_widgets()时发生foreach()错误,php,wordpress,foreach,Php,Wordpress,Foreach,这些是第305-314行 我得到了这个错误: function getWidgets($position = null) { if (empty($this->widgets)) { foreach (wp_get_sidebars_widgets() as $pos => $ids) { $this->widgets[$pos] = array(); foreach ($ids as $id) {
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);
}
}
}
}
有人能告诉我如何修复它吗?
wp\u get\u sidebars\u widgets()
返回一维数组
参考:
$ids
不是数组。不能在foreach
循环中遍历它
试试这个:
" 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 "
您的行号有点不正确,因为第310行是
$this->widgets[$pos][$id]=$this->getWidget($id)代码>但是错误引用了foreach循环中的参数。那么我该放什么呢。。说到.phpdid,我就不知所措了,在第255行得到了这样一条“警告:isset中的偏移量类型非法或/home/content/73/9889573/html/wp content/themes/yoo_spark_wp/warp/systems/wordpress.3.0/helpers/system.php中为空”
$widgets = array();
foreach (wp_get_sidebars_widgets() as $pos => $id) {
$widgets[$pos] = $this->getWidget($id);
}