Show your categories in two Columns!
I said about if and else with two or more single.php article. Also you can use this simple functions on your categories. You can show your categories in two columns. This a simple code and you can apply it only copy/paste :)
Here is the code;
We use wp_list_categories(); function when we calling our categories. But if we change this function we can change our category listing. Just copy and paste this function in your sidebar.php file and show your categories in two columns.
<?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;?>
</ul>
After that we have to change our style.css for left and right terms. her is the code;
.right {float:left; width:140px;}
.left {float:left; width:140px;}
That’s All. Have a nice day!
The Original Post: Blog-Oh-Blog

Recent Comments