Skip to content

Instantly share code, notes, and snippets.

@whyisjake
Last active December 10, 2015 18:59
Show Gist options
  • Save whyisjake/4478704 to your computer and use it in GitHub Desktop.
Save whyisjake/4478704 to your computer and use it in GitHub Desktop.
$args = array(
'category__in' => $cat_ID,
'posts_per_page' => 8,
'no_found_rows' => true,
);
$the_query = new WP_Query( $args );
//Maybe array_chunk isn't the right thing to do here...
$arrays = array_chunk( $the_query->posts, 4, true );
foreach( $arrays as $posts) {
//print_r($posts);
//Since there are two seperate arrays, this returns true for both of them...
if ($posts[0]) {
echo '<div class="item active">';
} else {
echo '<div class="item">';
}
echo '<div class="row">';
foreach ($posts as $post) {
echo '<div class="span3">';
echo get_the_post_thumbnail( $post->ID );
echo get_the_title( $post->ID );
echo '</div>';
}
echo '</div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment