I’m trying to create a blog page where i want to divide the posts in two columns. The current setup I’m using is using categories for each column. The ‘category 1’ posts will be shown on the left column and ‘category 2’ posts on the right.
I currently have the following code where I divided both columns using the grid method provided by the bootstrap framework. Where I am stuck is that wordpress keeps showing a single column page as shown here: http://imgur.com/RLeZLVQ
Any ideas why this is happening?
<div class="container">
<div class="row">
<div class="span6">
<?php query_posts('cat=1&showposts=10'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
<!-- Display the Post's content in a div box. -->
<div class="entry">
<?php the_content(); ?>
</div>
<!-- Display a comma separated list of the Post's Categories. -->
<p class="postmetadata">Posted in <?php the_category(', '); ?></p>
</div> <!-- closes the first div box -->
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php endwhile;?>
</div>
<div class="span6">
<?php query_posts('cat=2&showposts=10'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<!-- Display the date (November 16th, 2009 format) and a link to other posts by this posts author. -->
<small><?php the_time('F jS, Y') ?> by <?php the_author_posts_link() ?></small>
<!-- Display the Post's content in a div box. -->
<div class="entry">
<?php the_content(); ?>
</div>
<!-- Display a comma separated list of the Post's Categories. -->
<p class="postmetadata">Posted in <?php the_category(', '); ?></p>
</div> <!-- closes the first div box -->
<?php endwhile; else: ?>
<p><?php _e('Sorry, no posts matched your criteria.'); ?></p>
<?php endif; ?>
<?php endwhile;?>
</div>
</div>
The solution was a simple ‘duh’. Placed the code in single.php (single posts pages) instead of home.php (where all posts go). Anyway, the code as presented in the opening post works, for those interested!
Here’s the full code that you will have to place in home.php of your wordpress template for a 2 column page. Do note that you have to change the number after ‘cat=’ in
You have to change the number with the category ID of the posts that you want to have in each column. Category ID can be found in the WP admin screen under the post category tab. Select the category and check the URL for the ID.
you have an extra
</div>
in there after the first<?php endwhile;?>
this closes that rowyeah I am pretty sure that this is what is doing it