Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Page & Category Menu Bars (http://forum.bytesforall.com/forumdisplay.php?f=10)
-   -   How can I have my category widget display in two equal columns? (http://forum.bytesforall.com/showthread.php?t=4369)

barros1389 Nov 10, 2009 07:16 PM

How can I have my category widget display in two equal columns?
 
How can I have my category widget display it's categories in multiple columns?

It appears others have done something like the below code. However, I'm not sure where this would go?

Thanks in advance!



<?php
$get_cats = wp_list_categories( 'echo=0&title_li=&depth=1&hide_empty=0' );
// Get cats

$cat_array = explode('</li>',$get_cats);
// Split into array items

$columns = 4;
// How many columns (virtual)

$cats_shown = 0;
// Don't touch this, this is just a counter (used below)

echo '<ul style="display:inline;">';

foreach($cat_array as $category) {
$cats_shown++;

// The 2 lines below can be removed if you apply the style definitions to the classes (ie. cat-item, cat-item a etc..)
// This was just quicker and easier for me to use whilst testing the code.
$category = str_replace('<li','<li style="display:inline"',$category);
$category = str_replace('<a href','<a style="width:160px;display:block;float:left" href',$category);

if($cats_shown % $columns == 0) {
// If the counter is a multiple of the columns to show
print $category.'</li></ul><br /><ul style="display:inline;">';
}
else {
// Else just a regular item
print $category.'</li>';
}
}
echo '</ul>';
?>

juggledad Nov 11, 2009 06:14 AM

off the top, I'd guess they put it in the widget.

barros1389 Nov 11, 2009 06:31 PM

Well... I haven't installed any third party category plugin or widget. The category widget is the default installed when you install wordpress, and I'm using the Atahualpa theme, by the way and I love it. I just don't know where to add the above code to have multiple columns for the category widget.

juggledad Nov 11, 2009 06:45 PM

well it would have to go into the plugin's code, of course you better have a wide sidebar or there's not going to be much space for the comments...


All times are GMT -6. The time now is 01:24 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.