Skip to content

Instantly share code, notes, and snippets.

@emaildano
Created October 29, 2014 17:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emaildano/dd467ac99b8e634fa62e to your computer and use it in GitHub Desktop.
Save emaildano/dd467ac99b8e634fa62e to your computer and use it in GitHub Desktop.
Category loop w/ Bootstrap .row reset
<div class="container">
<?php single_cat_title(); ?>
<?php
$currentCat = single_cat_title( '', false );
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'orderby' => 'date',
'order' => 'DESC',
'category_name' => $currentCat,
);
$wp_query = new WP_Query( $args );
if ( $wp_query->have_posts() ) : ?>
<div class="row">
<?php $count=0; ?>
<?php while ( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
<?php // post content here ?>
<?php $count++; ?>
<?php if ($count==3 ||$wp_query->found_posts==0) : ?>
</div>
<div class="row">
<?php $count=0; ?>
<?php endif; ?>
<?php endwhile; ?>
<?php else :
// no posts
endif; ?>
<?php wp_reset_query(); ?>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment