I have a long list of categories. When I use the widget "Categories" the list scrolls down to the page. I want to display the list in 2 or 3 columns in the sidebar to improve the aesthetics.
Please Help.
Thank You.
I have a long list of categories. When I use the widget "Categories" the list scrolls down to the page. I want to display the list in 2 or 3 columns in the sidebar to improve the aesthetics.
Please Help.
Thank You.
you could try to apply a fixed width (just less than 50%/33% resp) and a 'float:left' to the category list elements;
details depend on your setup; a link to your site might help.
I found a code here
But how to use it for my sidebar ?
with that code, you would need to edit sidebar.php,
find a space that is shown even if you use widgets (either below or above the widgetized area),
and then add it there,
probably adjusting it to stay in keeping with your design.
Got it :)
Can you tell me how to edit the css ?
We can now easily style following with CSS: #cat-col-'.$list_number.' with '.$list_number.' being the⦠you guessed it, the number of your column.
Because every column will have its own number, do not forget that you will have to style all columns (#cat-col-1, #cat-col-2, #cat-col-3, #cat-col-4, #cat-col-5).
Thank You
After banging my head against the wall several times I finally found a really nice solution to this problem..
Downloaded the Custom Widget Plugin from here
Then added a widget with the following code:
<?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;
?>
<ul class="left">
<?php echo $cat_left;?><ul class="right">
<?php echo $cat_right;?>
Joy :D
This topic has been closed to new replies.