关于“Invalid arguments passed”的问题,求解 求大神点解。页面提示说:“Warning: implode(): Invalid arguments passed in /home/tumuneco/public_html/wp-content/themes/verge/carousel.php on line 8”但是我不懂php,搞不懂改怎么修改 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 图好像有点小,具体代码如下:<?php global $option_setting;$count = 1;if (isset($option_setting['carousel-enable-on-home'])) : if( $option_setting['carousel-enable-on-home'] && (is_front_page() || is_home() )) : ?> <div id="carousel-wrapper" class="container"> <ul class="bxcarousel"> <?php $args = array( 'posts_per_page' => $option_setting['carousel-count'], 'category' => implode(",",$option_setting['carousel-cats']) ); $lastposts = get_posts( $args ); foreach ( $lastposts as $post ) : setup_postdata( $post ); ?> <li><a title="<?php the_title(); ?>" href='<?php the_permalink(); ?>'> <?php if (has_post_thumbnail()) : $thumb_id = get_post_thumbnail_id(); $thumb_url = wp_get_attachment_image_src($thumb_id,'carousel', true); echo "<img class='carousel-image' src='".$thumb_url[0]."' title='".get_the_title()."'>"; else : echo "<img class='carousel-image' src='".get_template_directory_uri()."/assets/images/placeholder2.jpg' title='".get_the_title()."'>"; endif; ?></a></li> <?php endforeach; wp_reset_postdata(); ?> </ul> </div> <?php endif;endif;?> 错误原因:$option_setting['carousel-cats']不是数组 需要打印出来是什么类型 var_dump($option_setting);输出来是什么? var_dump(isset($option_setting['carousel-cats']));print_r($option_setting['carousel-cats']);看看是否為空。 $args = array( 'posts_per_page' => $option_setting['carousel-count'], 'category' => implode(",",$option_setting['carousel-cats']) );改为:$category = isset($option_setting['carousel-cats'])? implode(",",$option_setting['carousel-cats']) : '';$args = array( 'posts_per_page' => $option_setting['carousel-count'], 'category' => $category ); $args = array( 'posts_per_page' => $option_setting['carousel-count'], 'category' => implode(",",$option_setting['carousel-cats']) );改为:$category = isset($option_setting['carousel-cats'])? implode(",",$option_setting['carousel-cats']) : '';$args = array( 'posts_per_page' => $option_setting['carousel-count'], 'category' => $category );这样就可以避免为空出现警告了。 求教word文档格式成网页填写并打印出相同效果的实现 Ext在外面企业受不受欢迎呢 小弟遇见很诡异的问题.. 求如何获取系统时间函数 各位大侠,快来帮帮忙,有关php在iis中配置的问题,急急. 新手请教!PHP基础问题!(在线等待!) 变量值传递问题! 如何使用phpedit编程和php? 请问各位高手:在聊天室里如何查看对方的ip? linux+thinkphp+gd验证码无法显示 TP3.2 select下的标签怎么能实现二级栏目分类? 火狐和AJAX返回的是Object XMLDocument
<?php global $option_setting;
$count = 1;
if (isset($option_setting['carousel-enable-on-home'])) :
if( $option_setting['carousel-enable-on-home'] && (is_front_page() || is_home() )) : ?>
<div id="carousel-wrapper" class="container">
<ul class="bxcarousel">
<?php
$args = array( 'posts_per_page' => $option_setting['carousel-count'], 'category' => implode(",",$option_setting['carousel-cats']) );
$lastposts = get_posts( $args );
foreach ( $lastposts as $post ) :
setup_postdata( $post ); ?>
<li><a title="<?php the_title(); ?>" href='<?php the_permalink(); ?>'>
<?php if (has_post_thumbnail()) :
$thumb_id = get_post_thumbnail_id();
$thumb_url = wp_get_attachment_image_src($thumb_id,'carousel', true);
echo "<img class='carousel-image' src='".$thumb_url[0]."' title='".get_the_title()."'>";
else :
echo "<img class='carousel-image' src='".get_template_directory_uri()."/assets/images/placeholder2.jpg' title='".get_the_title()."'>";
endif; ?></a></li>
<?php endforeach;
wp_reset_postdata();
?>
</ul>
</div>
<?php endif;
endif;?>
$option_setting['carousel-cats']不是数组
需要打印出来是什么类型
print_r($option_setting['carousel-cats']);看看是否為空。
$args = array( 'posts_per_page' => $option_setting['carousel-count'], 'category' => implode(",",$option_setting['carousel-cats']) );
改为:$category = isset($option_setting['carousel-cats'])? implode(",",$option_setting['carousel-cats']) : '';
$args = array( 'posts_per_page' => $option_setting['carousel-count'], 'category' => $category );
$args = array( 'posts_per_page' => $option_setting['carousel-count'], 'category' => implode(",",$option_setting['carousel-cats']) );
改为:$category = isset($option_setting['carousel-cats'])? implode(",",$option_setting['carousel-cats']) : '';
$args = array( 'posts_per_page' => $option_setting['carousel-count'], 'category' => $category );这样就可以避免为空出现警告了。