Last active
December 20, 2015 23:49
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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