0

I have a slider that i'd like to load 3 blog posts into each slide. I'm having a problem getting them all out correctly. I'm using Flexslider. The idea is to get 3 blog posts at a time into each slide.

any help would be greatly appreciated!

My Markup: - I need each 3 posts go into the li

<?php $argsb = array('posts_per_page' => 3, 'post_status' => 'publish');?>
<?php $blog = new WP_Query($argsb); if ( $blog->have_posts() ):?>
<section class="blog-slider slider">
<div class="flexslider">
<ul class="slides">
<li class="slide">
<?php  while ( $blog->have_posts() ) : $blog->the_post(); $count++;?>
<article class="blog-post-slide<?php if ( 0 == $count%2 ) {echo' middle-blog-slide';} ?>">
<?php if ( has_post_thumbnail() ) {?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><div class="blog-slide-image"><?php the_post_thumbnail('blog-slide');?></div></a>
<?php } ?>
<?php the_title();?>
</article>
<?php endwhile; wp_reset_postdata();?>
</li>
</ul>
</div>
</section>
<?php endif; ?>
0

I ended up doing this - works perfectly.

<?php $argsb = array('posts_per_page' => -1, 'post_status' => 'publish');?>
<?php  $blog = new WP_Query($argsb); if ( $blog->have_posts() ): ?>
<section class="blog-slider slider">
<div class="flexslider">
<ul class="slides">
<?php  while ( $blog->have_posts() ) : $blog->the_post(); $i++;?>
<?php if( $blog->current_post % 3 == 0 ) echo "\n".'<li class="slide">'."\n"; ?>
<article class="blog-post-slide">
<?php if ( has_post_thumbnail() ) {?>
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><div class="blog-slide-image"><?php the_post_thumbnail('blog-slide');?></div></a>
<?php } ?>
<?php the_title();?>
</article>

<?php if( $blog->current_post % 3 == 2 ) echo '</li> <!--/.wrap-->'."\n"; ?>

<?php endwhile; wp_reset_postdata();?>

</ul>
</div>
</section>
<?php endif; ?>

Not the answer you're looking for? Browse other questions tagged or ask your own question.