Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 使用wordpress wp_get_边栏_widgets()时发生foreach()错误_Php_Wordpress_Foreach - Fatal编程技术网

Php 使用wordpress wp_get_边栏_widgets()时发生foreach()错误

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) {

这些是第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) {                  // 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);
}