【问题标题】:Wordpress slider with 4 posts per slideWordpress 滑块,每张幻灯片 4 个帖子
【发布时间】:2014-06-13 00:17:52
【问题描述】:

我正在开发一个包含帖子滑块(特定类别的帖子)的项目。没问题。但是滑块应该一次显示 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)

【问题讨论】:

    标签: javascript php jquery wordpress


    【解决方案1】:

    使用 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 
    }
    

    希望对你有用。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-06-24
      • 1970-01-01
      • 2016-10-25
      • 1970-01-01
      • 2012-05-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多