I´m trying to make a slider which takes thumbnails from a certain custom post type and displays for of them for each “slide”. I get the slider and thumbnails to work like they should, but I´m unsure of how I should modify the loop to get it to display 4 posts in a container, then repeat with the next 4 posts and so on.
My loop looks like this:
<div id="slides">
<div class="slides_container">
<?php $loop = new WP_Query(array('post_type' => 'fastighet', 'posts_per_page' => -1, 'orderby'=> 'ASC')); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div class="slide">
<?php $url = get_post_meta($post->ID, "url", true);
if($url!='') {
echo '<a href="'.$url.'">';
echo the_post_thumbnail('admin-list-thumb');
echo '</a>';
} else {
echo the_post_thumbnail('admin-list-thumb');
} ?>
<div class="caption">
<h5><?php the_title(); ?></h5>
</div>
</div>
<?php endwhile; ?>
<?php wp_reset_query(); ?>
</div> <!-- end .slides_container -->
<a href="#" class="prev">prev</a>
<a href="#" class="next">next</a>
</div> <!-- end .slides -->
Every div with the class of slide becomes a slide as you can see. But how can I make it put 4 posts into each such slide, then 4 post more into another slide etc.
Any help or tips would be really appreciated!