Displaying the first, second, and third posts from a category in separate slides

I’ve searched around and I haven’t been able to find a solution for exactly what I’m trying to do.

I have this basic JavaScript slider from w3c that displays one slide at a time. I’m trying to get each slide to display a different post from a specific category from the loop. Slide #1 should contain the most recent post, slide #2 should contain the second, and slide #3 should contain the third.

This is what I have right now, but it only displays the first post in each of the slides:

<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>

I’d like to accomplish this without a plugin, so my client can just tick the “Featured” category and have the post show up there.

Thank you!

Read more here:: Displaying the first, second, and third posts from a category in separate slides

Leave a Reply

Your email address will not be published. Required fields are marked *