Three column posts in Wordpress
Jun29th
2009
••
Here is a working example of this.
Following up on my two column post hack for Wordpress, here is a method to doing it for three columns. There isn’t really too much different except a few small shanges in the CSS and PHP. Biggest change is using PHPs ceil() instead of round().
Take a look at the whole code first:
<?php
$content = apply_filters('the_content', $post->post_content);
$beth = explode('<p>', $content);
$i = 0;
foreach ($beth as $erica){
$i++;
$q = $i - 1;
if ($i == 0) {
echo $q.$erica;
}
}
$z = $q/3;
$i = 0;
echo "<div class='left l1'>\n";
foreach ($beth as $erica){
$i++;
$q = $i - 1;
if ($i != 1) {
// un-comment the next line
//echo "<p>".$erica;
//erase or comment out the next line
echo "<p>".$q.") ".$erica;
}
if ($i == ceil($z+1)){
echo "</div>\n\n<div class='left l2'>\n";
}
if ($i == ceil($z+$z+1) ){
echo "</div>\n\n<div class='left l3'>\n";
}
}
echo "</div>\n\n"
?>






