This code is poweful but definitely easy to implement. Just paste it on your functions.php file and it will automatically output your post content in columns.
Your post content will be splitted on <h2> tags.
function my_multi_col($content){
$columns = explode('<h2>', $content);
$i = 0;
foreach ($columns as $column){
if (($i % 2) == 0){
$return .= '<div class="content_left">' . "\n";
if ($i > 1){
$return .= "<h2>";
} else{
$return .= '<div class="content_right">' . "\n <h2>";
}
$return .= $column;
$return .= '</p></div>';
$i++;
}
if(isset($columns[1])){
$content = wpautop($return);
}else{
$content = wpautop($content);
}
echo $content;
}
}
add_filter('the_content', 'my_multi_col');
Don’t forget to add the following styles to your style.css file :
.content_right, .content_left{
float:left;
width:45%;
}
.content_left{
padding-right:5%;
}
Thanks to www.kriesi.at for contributing this great function to the community!

Dec 9, 2009
cosmos
category :
Visited 535 , 1 Today
Tags: 





