警告:implode()[function.implode]:传递的参数无效 [英] Warning: implode() [function.implode]: Invalid arguments passed

查看:595
本文介绍了警告:implode()[function.implode]:传递的参数无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在下面出现错误...

I'm getting the error below...

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

Warning: implode() [function.implode]: Invalid arguments passed in \wp-content/themes/mytheme/functions.php on line 1335

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>';
}

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

Any ideas how to intercept the error. The site has exactly one tag.

推荐答案

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

You are getting the error because $ret is not an array.

为了摆脱错误,在函数开始时,用这一行定义它: $ ret = array();

To get rid of the error, at the start of your function, define it with this line: $ret = array();

看起来get_tags()调用什么也没有返回,所以foreach没有运行,这意味着$ ret未定义。

It appears that the get_tags() call is returning nothing, so the foreach is not run, which means that $ret isn't defined.

这篇关于警告:implode()[function.implode]:传递的参数无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆