我到处找了找,还没能找到一个确切的解决方案来解决我要做的事情。
我有this basic JavaScript slider from w3c 一次显示一张幻灯片的。我试图让每张幻灯片显示循环中特定类别的不同帖子。幻灯片#1应包含最近发表的文章,幻灯片#2应包含第二篇,幻灯片#3应包含第三篇。
这是我现在看到的内容,但它只显示每张幻灯片中的第一篇帖子:
<div class="slideshow-container">
<div class="mySlides fade">
<div class="numbertext">1 / 3</div>
<?php
query_posts("current_post=0&showposts=1&cat=1"); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?the_post_thumbnail( \'large\' ); ?>
</a>
<div class="text"><?php the_title(); ?></div>
<?php endwhile; else : ?>
<p><?php _e( \'Sorry, no posts matched your criteria.\' ); ?></p>
<?php endif; ?>
<?php wp_reset_query(); ?>
<?php rewind_posts(); ?>
</div>
<div class="mySlides fade">
<div class="numbertext">2 / 3</div>
<<?php query_posts("current_post=1&showposts=1&cat=1"); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?the_post_thumbnail( \'large\' ); ?>
</a>
<div class="text"><?php the_title(); ?></div>
<?php endwhile; else : ?>
<p><?php _e( \'Sorry, no posts matched your criteria.\' ); ?></p>
<?php endif; ?>
<?php wp_reset_query(); ?>
<?php rewind_posts(); ?>
</div>
<div class="mySlides fade">
<div class="numbertext">3 / 3</div>
<<?php query_posts("current_post=2&showposts=1&cat=1"); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<?the_post_thumbnail( \'large\' ); ?>
</a>
<div class="text"><?php the_title(); ?></div>
<?php endwhile; else : ?>
<p><?php _e( \'Sorry, no posts matched your criteria.\' ); ?></p>
<?php endif; ?>
<?php wp_reset_query(); ?>
<?php rewind_posts(); ?>
</div>
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
我希望在没有插件的情况下完成这项工作,这样我的客户端就可以勾选“特色”类别,并将帖子显示在那里。非常感谢。