All of Our Themes, work without any worries on WordPress 2.8

How To Display your categories in two columns

ADVERTISEMENTS

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% [?]




4 Comments Add Yours ↓

The upper is the most recent comment

  1. 1

    Thank you

  2. 2

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

    ???

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

  3. Investpanas #
    3

    thank you this blog very nice

  4. Joe #
    4

    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

Your Comment

Comments links could be nofollow free.