Display category / archives on two columns [WordPress Sidebar]

In most WordPress themes, categories si archives Blog listed in sidebar.php (Ie side column of the blog). For those who have many archives and categories in blog space in sidebar is considerably reduced and the blog page is very long.
Here is a solution to list categories and / or the blog archives in sidebar on two columns uniformWithout need of any Plugin. Gender:

wp-2

In WordPress, categories listing code is: <? Php wp_list_categories ();?> . Listing categories in two columns is very simple. Replace in sidebar.php code <? Php wp_list_categories ();?> with:

<? 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]. "</ Li> ';
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;?>

In CSSWordPress theme site (style.css) Add:

. Right {float: left; width: 110px;}
. Left {float: left; width: 110px;}

Dimensions width: 110px may vary depending on the width of your sidebar

Display category / archives on two columns [WordPress Sidebar]

About the author

Stealth

Passionate about everything that means gadget and IT, I am pleased to write on stealthsettings.com from 2006 and I love to discover new things about computers and macOS, Linux operating systems, Windows, iOS and Android.

Leave a Comment