Created
October 29, 2014 17:41
-
-
Save emaildano/dd467ac99b8e634fa62e to your computer and use it in GitHub Desktop.
Category loop w/ Bootstrap .row reset
This file contains 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
<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