关于“Invalid arguments passed”的问题,求解

palmhua 2014-12-31 04:48:53



求大神点解。
页面提示说:“Warning: implode(): Invalid arguments passed in /home/tumuneco/public_html/wp-content/themes/verge/carousel.php on line 8”
但是我不懂php,搞不懂改怎么修改
...全文
2034 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
傲雪星枫 2017-09-17
  • 打赏
  • 举报
回复

$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 );
这样就可以避免为空出现警告了。
傲雪星枫 2017-09-15
  • 打赏
  • 举报
回复

$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 );
Cicc_1509 2017-09-15
  • 打赏
  • 举报
回复
引用 5 楼 fdipzone 的回复:
var_dump(isset($option_setting['carousel-cats'])); print_r($option_setting['carousel-cats']); 看看是否為空。
为空怎么办
傲雪星枫 2015-01-02
  • 打赏
  • 举报
回复
var_dump(isset($option_setting['carousel-cats'])); print_r($option_setting['carousel-cats']); 看看是否為空。
码无边 2015-01-02
  • 打赏
  • 举报
回复
var_dump($option_setting);输出来是什么?
palmhua 2014-12-31
  • 打赏
  • 举报
回复
引用 2 楼 orangeholic 的回复:
错误原因: $option_setting['carousel-cats']不是数组 需要打印出来是什么类型
需要怎么修改呢?
侑子的小伙伴 2014-12-31
  • 打赏
  • 举报
回复
错误原因: $option_setting['carousel-cats']不是数组 需要打印出来是什么类型
palmhua 2014-12-31
  • 打赏
  • 举报
回复
图好像有点小,具体代码如下:
<?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;?>

21,886

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧