mardi 24 février 2015

Show category list on three column with description [on hold]


I want to ask how to display a description of each category with three column list.



<?php
// Grab the categories - top level only (depth=1)
$get_cats = wp_list_categories( 'echo=0&title_li=&depth=1&hide_empty=0' );
// Split into array items
$cat_array = explode('</li>',$get_cats);
// Amount of categories (count of items in array)
$results_total = count($cat_array);
// How many categories to show per list (round up total divided by 3)
$cats_per_list = ceil($results_total / 3);
// Counter number for tagging onto each list
$list_number = 1;
// Set the category result counter to zero
$result_number = 0;
?>
<ul class="cat_col" id="cat-col-<?php echo $list_number; ?>">
<?php
foreach($cat_array as $category) {
$result_number++;

if($result_number % $cats_per_list == 0) {
$list_number++;
echo $category.' '.$cat->description.'</li>
</ul>
<ul class="cat_col" id="cat-col-'.$list_number.'">';
}
else {
echo $category.';
</li>';
}
}
?>


Thank you very much.





Aucun commentaire:

Enregistrer un commentaire