Sometimes you have a lot of categories, you cannot simply list them down as one column. In such a case you would like to have it displayed in multiple columns. We will use wordpress built-in functions to list categories, so that any new ones are automatically added to the list.
You can display the category names in footer in 2 or columns in your theme. This can be done by using wp_list_categories() and playing with some mathematics. Normally you can find code that displays category names in two columns but this snippet will do it in as many columns as you want. Have a look at this tip and you will love it!!

// Grab top level categories (depth=1)
$get_cats = explode("<br />",wp_list_categories('title_li=&echo=0&show_count=1&depth=1&style=none&hierarchical=0&feed=RSS'));

 $results_total = count($get_cats);
  $results_total= $results_total-1;
 // How many categories to show per list (round up total divided by 5)

 $cats_per_list = ceil($results_total / 4);
 // Counter number for tagging onto each list
 $list_number = 1;
 // Set the category result counter to zero
 $result_number = 0;?>
<ul class="category_footer_post" id="cat-col-<?php echo $list_number; ?>">
<?php        foreach($get_cats as $category)
			{        $result_number++;
 if($result_number % $cats_per_list == 0) {


  echo '<li>'.$category[0].'</li>        </ul>          <ul class="category_footer_post" id="cat-col-'.$list_number.'">';     }
    else {         echo '<li>'.$category[0].'</li>';         }
	    } ?> </ul>


Yumna Tatheer

I am a Computer Science graduate and a part time blogger from Lahore, Pakistan. I am a PHP programmer and a wordpress expert.

More Posts

Follow Me: