1
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 " 

誰か教えてくれませんか

4

1 に答える 1

2

wp_get_sidebars_widgets()1 次元配列を返します。

参照: 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);
}
于 2012-09-25T21:20:13.363 に答える