关于“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 );这样就可以避免为空出现警告了。 如何读出这种数据的内容 多谢!!!!! 求模拟登录新浪微博登录时验证码问题 php 文件下载 switch语句的几个疑问 这句SQL怎么错了呢,谢谢 简单问题,web服务器和mysql服务器 js变量值赋给php变量的问题 PHP可以处理存储过程返回的游标或记录集的吗? 唠叨老大用不用cvs的?大家有多少人知道? 请问如何配置php才能使php支持sql server呢? 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 );这样就可以避免为空出现警告了。