【问题标题】:Rocco Theme Functions error implodeRocco 主题函数错误内爆
【发布时间】:2015-10-08 14:21:20
【问题描述】:

我在我的网站上收到此错误:

警告:array_map() [function.array-map]:参数 #2 应该是第 86 行 /home/content/77/12366977/html/wp-content/themes/rocco/functions.php 中的一个数组

警告:implode() [function.implode]:第 86 行 /home/content/77/12366977/html/wp-content/themes/rocco/functions.php 中传递的参数无效


我认为发生错误的行是这一行: * 摘录 * ------------------------------------------------- -------------------------- */ 函数 mfn_excerpt($post, $length = 55, $tags_to_keep = '', $extra = ' [...]') {

if(is_int($post)) {
    $post = get_post($post);
} elseif(!is_object($post)) {
    return false;
}

if(has_excerpt($post->ID)) {
    $the_excerpt = $post->post_excerpt;
    return apply_filters('the_content', $the_excerpt);
} else {
    $the_excerpt = $post->post_content;
}

$the_excerpt = strip_shortcodes(strip_tags($the_excerpt, $tags_to_keep));
$the_excerpt = preg_split('/\b/', $the_excerpt, $length * 2+1);
$excerpt_waste = array_pop($the_excerpt);
$the_excerpt = implode($the_excerpt);
if( $excerpt_waste ) $the_excerpt .= $extra;

return apply_filters('the_content', $the_excerpt);

如果添加代码是解决方案,我应该做什么以及应该在哪里添加代码? 非常感谢您的帮助!

【问题讨论】:

    标签: php wordpress function themes implode


    【解决方案1】:

    首先PHP implode 接受两个参数,如果explode 不是标准的并且可能就是这种情况。你只用了一个

    您的示例中也没有“array_map”。真的是一样的代码吗?

    【讨论】:

    • 我不确定,因为我没有看到 array_map 代码。
    • * ----------------------------------------- -------------------------------- */ 函数 mfn_get_comment_excerpt($comment_ID = 0, $num_words = 20) { $comment = get_comment($comment_ID); $comment_text = strip_tags($comment->comment_content); $blah = explode(' ', $comment_text); if (count($blah) > $num_words) { $k = $num_words; $use_dotdot = 1; } 其他 { $k = count($blah); $use_dotdot = 0; } $摘录 = '';对于 ($i=0; $i
    • 我的网站是 stephaniesander.com
    猜你喜欢
    • 2012-01-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-24
    • 2016-10-07
    • 1970-01-01
    • 2019-04-27
    • 1970-01-01
    相关资源
    最近更新 更多