Wordpress滑块,每张幻灯片有4个帖子

时间:2014-06-13 00:17:53

标签: javascript php jquery wordpress

我正在开发一个项目,其中包含一个帖子的滑块(特定类别的帖子)。没问题。但是滑块应该同时显示4个帖子(类似于每个幻灯片上的帖子网格)。知道如何解决这个问题吗?这是我用来打印滑块中的帖子的代码。这是我的第二个WordPress项目,我对PHP没有多少了解。感谢您的关注并抱歉我的英语不好!

<ul class="slides">
<?php
query_posts(array('category_name' => 'marcar-na-timeline'));
if(have_posts()) : while(have_posts()) : the_post();
?>
<li>
<ul>
<li class="item">
<a href="<?php echo get_permalink(); ?>" class="post-item-container<?php echo $opener_class; ?>">
<div class="thumb"><?php the_post_thumbnail('thumbnail');?></div>
<div class="item-content">
<div class="date">
<span class="day"><?php the_time('d'); ?></span>
<span class="monthandyear"><?php the_time('M y'); ?></span>
</div>
<div class="item-description">
<?php echo get_uf('description'); ?>
</div>
<div class="clear"></div>
</div>
</a>
</li>
</ul>
</li>
<?php
   endwhile;
endif;
wp_reset_query();
?>
</ul>

(我使用flexslider)

1 个答案:

答案 0 :(得分:0)

使用WP_Query类:

$slider_post= new WP_Query('category_name='your catagory name'& showposts=4');
if($slider_post -> have_post()) : while($slider_post->have_post()){
      $slider_post->the_post();
      // echo html slider item 
}

我希望它对你有用。