How To Display your categories in two columns

display-categories-in-two-columns

The stadard wp_list_categories() functions echoes a list of all your categories. With this simple trick we can display the categories in two columns. This code is easy to implemented and doesn’t need high level skill to add on our theme. Just paste this code on your theme file and you are ready to split your wp_list_categories()

< ?php
$cats = explode("<br />",wp_list_categories('title_li=&echo=0&depth=1&style=none'));
$cat_n = count($cats) - 1;
for ($i=0;$i< $cat_n;$i++):
if ($i<$cat_n/2):
$cat_left = $cat_left.'<li>'.$cats[$i].'';
elseif ($i>=$cat_n/2):
$cat_right = $cat_right.'<li>'.$cats[$i].'</li>';
endif;
endfor;
?>
<ul class="left">
< ?php echo $cat_left;?>
</ul>
<ul class="right">
< ?php echo $cat_right;?>
</ul>

After you copy this code and save it. Thanks to Blog Oh Blog and WP Recipes that share this tricks

Popularity: 2% [?]

PG

Author: Jauhari

This is me Nurudin Jauhari. Just human like you, I come from Gunungkidul, small place at Yogyakarta, and Today I live at Malang I was born 30/04/1980 in Ponjong, small village in Gunungkidul, Almost my time in 1 - 15 Years stay at this Village. More
ADVERTISEMENTS

| More


5 Comments

  1. preety nice tweak

  2. Thank you

  3. $cat_left = $cat_left.'<li>'.$cats[$i].'';

    ???

    $cat_left = $cat_left.'<li>'.$cats[$i].'</li>';

  4. Investpanas

    thank you this blog very nice

  5. Thank you, thank you, thank you! Coding is still so complicated sometimes.


2 Trackbacks/Pingbacks

  1. How To Display your categories in two columns JAUHARI | Wood TV Stand 01 06 09
  2. Wordpress How To Articles - May 24, 2009 24 05 09

Add Your Comment

Comments links could be nofollow free.