警告:implode() [function.implode]:传递的参数无效

2024-04-29

我收到以下错误...

警告: implode() [function.implode]:在第 1335 行的 \wp-content/themes/mytheme/functions.php 中传递的参数无效

at...

function my_get_tags_sitemap(){
    if ( !function_exists('wp_tag_cloud') || get_option('cb2_noposttags')) return;
    $unlinkTags = get_option('cb2_unlinkTags'); 
    echo '<div class="tags"><h2>Tags</h2>';
    if($unlinkTags)
    {
        $tags = get_tags();
        foreach ($tags as $tag){
            $ret[]= $tag->name;
        }
        //ERROR OCCURS HERE
        echo implode(', ', $ret);
    }
    else
    {
        wp_tag_cloud('separator=, &smallest=11&largest=11');
    }
    echo '</div>';
}

任何想法如何拦截错误。该网站只有一个标签。


您收到错误是因为$ret不是一个数组。

要消除该错误,请在函数的开头使用以下行定义它:$ret = array();

看起来 get_tags() 调用没有返回任何内容,因此 foreach 没有运行,这意味着 $ret 没有定义。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

警告:implode() [function.implode]:传递的参数无效 的相关文章

随机推荐