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()

[sourcecode language=’php’]
< ?php $cats = explode("
“,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.'

  • ‘.$cats[$i].”;
    elseif ($i>=$cat_n/2):
    $cat_right = $cat_right.’

  • ‘.$cats[$i].’
  • ‘;
    endif;
    endfor;
    ?>

      < ?php echo $cat_left;?>
      < ?php echo $cat_right;?>

    [/sourcecode]

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

    10 thoughts on “How To Display your categories in two columns

    1. Ping-balik: Green Earth Justin

    Tinggalkan Balasan

    Alamat email Anda tidak akan dipublikasikan. Ruas yang wajib ditandai *

    This site uses Akismet to reduce spam. Learn how your comment data is processed.