Skip to content

Instantly share code, notes, and snippets.

@MikeRogers0
Last active December 20, 2015 23:49
Show Gist options
  • Save MikeRogers0/6215259 to your computer and use it in GitHub Desktop.
Save MikeRogers0/6215259 to your computer and use it in GitHub Desktop.
Question: Instead of each post going into it's own <li>, what if I wanted three posts per <li> element? Answer: loop
<ul class="slides">
<li>
<?php
$count = 0;
query_posts('post_type=testimonials&posts_per_page=-1'); if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<h3>
<?php the_post_thumbnail(); ?>
<?php the_title();?>
<span><?php the_field('job_position'); ?></span>
</h3>
<?php the_content();?>
<span class="website">View website in action: <a title="View <?php the_field('website_name'); ?>" href="<?php the_field('website_link'); ?>"><?php the_field('website_name'); ?></a></span>
// Every 3rd loop, reset the li.
<?php if ($count == 2){ ?></li>
<?php if(get_next_post() != ''){ ?><li><?php } ?>
<?php $count = 0; }else {$count++;} ?>
<?php endwhile; wp_reset_query(); ?>
</li>
</ul>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment