tonyparra |
02-24-2012 11:03 AM |
Wordpress Ninjas help please: Display categories in columns with post count
Trying to do something like at tubegalore.com where they show show a list of categories, in columns, with the number of videos per category but in wordpress obviously it would be post per category.
I found some php that will display 3 columns but im trying to find a better way
Code:
<?php
$catArray = explode("</li>",wp_list_categories('title_li=&echo=0&depth=1'));
$catCount = count($catArray) - 1;
$catColumns = round($catCount / 3);
$twoColumns = round($catColumns + $catColumns);
for ($i=0;$i<$catCount;$i++) {
if ($i<$catColumns){
$catLeft = $catLeft.''.$catArray[$i].'</li>';
}
elseif ($i<$twoColumns) {
$catMiddle = $catMiddle.''.$catArray[$i].'</li>';
}
elseif ($i>=$catColumns){
$catRight = $catRight.''.$catArray[$i].'</li>';
}
};
?>
<ul class="left">
<?php echo $catLeft; ?>
</ul>
<ul class="middle">
<?php echo $catMiddle; ?>
</ul>
<ul class="right">
<?php echo $catRight; ?>
</ul>
|