Last active
August 29, 2015 14:04
-
-
Save themeblvd/c810ac27369d8c2481df to your computer and use it in GitHub Desktop.
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
<?php | |
function my_post_grid() { | |
global $wp_query; | |
global $post; | |
// Open first row | |
echo '<div class="row">'; | |
$i = 1; | |
while ( have_posts() ) { | |
the_post(); | |
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' ); // We want the URL to the full size image | |
?> | |
<div class="col-sm-3"> | |
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> | |
<h2 class="entry-title"><?php the_title(); ?></h2> | |
<a href="<?php echo $thumb[0]; ?>" class="themeblvd-lightbox mfp-image"> | |
<?php the_post_thumbnail('grid_3'); ?> | |
</a> | |
<?php the_content(); ?> | |
</div> | |
</div> | |
<?php | |
// Every 4th post, but not the very last post | |
if ( $i % 4 == 0 && $i != $wp_query->post_count ) { | |
// Close current row | |
echo '</div><!-- .row (end) -->'; | |
// Open next row | |
echo '<div class="row">'; | |
} | |
// Increment the counter | |
$i++; | |
} | |
// End final row | |
echo '</div><!-- .row (end) -->'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment