How To Create Double Posts Columns On The Homepage

Filed Under (Customization And Themes, How To, Installation) by Wpfeed on 10-06-2009

press75.com

From time to time you need to change some things from the WordPress default. One of the easiest hacks to do is creating double posts columns.

all you need is a bit PHP and some Css tweaking, here is the example:

CSS

.row {clear:both;}
.col1 {width:300px;float:left;padding:10px;}
.col2 {width:300px;float:right;padding:10px;}

* change the width of the columns according to what you need.

in your index.php (in the theme folder) look for the posts loop and before that paste this:

<?php $col = 1; ?>

after the loop begins add this:

<?php if ($col == 1) echo “<div class=\”row\”>”; ?>

now inside the loop, replace the loop main DIV with this code:

<div class=”post col<?php echo $col;?>” id=”post-<?php the_ID(); ?>”>

and just before the end replace ENDWHILE with this:

<?php if ($col == 1) echo “</div>”; (($col==1) ? $col=2 : $col=1); endwhile; ?>

THAT’S IT.

here are the sources for this post:

http://netcovered.com/wordpress-posts-in-different-columns/

http://www.cre8d-design.com/blog/2008/03/01/how-to-organize-posts-into-two-side-by-side-columns-in-wordpress/

Blog Widget by LinkWithin
Wpfeed

All info you ever needed about WordPress.

Popularity: 8% [?]



Comments:

Post a comment

Theme Forest
Theme Trust
elegant themes
press75.com
ithemes
wopshow

free wordpress 3.0 theme - wp3theme Theme