Skip to content

Instantly share code, notes, and snippets.

@emaildano
Created February 13, 2014 21:57
Show Gist options
  • Save emaildano/8984708 to your computer and use it in GitHub Desktop.
Save emaildano/8984708 to your computer and use it in GitHub Desktop.
Bootstrap row reset query example.
<?php
/*
Template Name: Trainers Template
*/
?>
<div class="trainers-grid">
<?php
$args = array(
'post_type' => 'trainers',
'posts_per_page' => -1,
);
$wp_query = new WP_Query( $args );
if ( $wp_query->have_posts() ) : ?>
<div class="row trainers-grid-row">
<?php $count=0; ?>
<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
<div class="col-sm-4 trainers-thumbnail">
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail('full', array('class' => 'img-responsive'));
}
?>
<div class="title"><?php the_title(); ?></div>
</div>
<?php $count++; ?>
<?php if ($count==3 ||$wp_query->found_posts==0) : ?>
</div>
<div class="row trainers-grid-row">
<?php $count=0; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php else : ?>
<h3>Sorry but there are no portfolio items.</h3>
<?php endif; ?>
<?php wp_reset_query(); ?>
</div>
</div><!-- trainers-grid -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment