Responsive 3 Column Posts in Category Page with WordPress and Bootstrap 3.0

Ever wonder of how to create responsive grid layout for your WordPress category page?
Medialoot explained this before in detailed way. But how to make a simple responsive category page that only has 3 column posts in WordPress using Bootstrap 3?
I simplified in a bit what Medialoot has explained in their blog and here’s how.

Just open your category.php or create any category template file if you want to have this layout to be only shown for specific category.

Let’s take a look of the code:

{code type=codetype}

<?php /* Start the Loop */ ?>

<?php while ( have_posts() ) : the_post(); ?>

//Set the initial count outside of the loop.
$count = (int)0;

<ul class=”thumbnails”>

//Set the span to our default span12
$span = ‘col-md-4’;

//then reset the count to 0

if($count >= 12){
$count = 0;
//If its not 3 or higher, increase the count

<li class=”<?php echo $span; ?>”>

<a href=”<?php the_permalink(); ?>”>

<h1 >

$thetitle = $post->post_title; /* or you can use get_the_title() */
$getlength = strlen($thetitle);
$thelength = 23;
echo substr($thetitle, 0, $thelength);
if ($getlength > $thelength) echo “…”;

<?php the_post_thumbnail( ‘medium’, array( ‘class’ => ‘thumbnail’ ) ); ?>
<div class=”description”> <?php the_excerpt() ?></div>



This code will result equal size of post thumbnails with each of their post title and description within 3 columns. Sometimes you need to limit the characters for the post title like I showed you in the code, because if not, the layout will not display in perfect rows and columns or can display something like masonry layout.

View Demo