Wordpress Themes - WP Forum at BFA
There will be no more development for Atahualpa (or any other theme), and no support. Also no new registrations. I turned off the donation system. I may turn the forum to read only if it gets abused for spam. Unfortunately I have no time for the forum or the themes. Thanks a lot to the people who helped in all these years, especially Larry and of course: Paul. Take care and stay healthy -- Flynn, Atahualpa developer, Sep 2021

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme » Page & Category Menu Bars »

How can I have my category widget display in two equal columns?


 
Prev Previous Post   Next Post Next
  #1  
Old Nov 10, 2009, 07:16 PM
barros1389's Avatar
barros1389
 
6 posts · Oct 2009
Boston
Send a message via AIM to barros1389
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>';
?>
 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to horizontally display the Category Posts Widget ? bryan85 Plugins & Atahualpa 0 Sep 6, 2009 06:28 PM
[SOLVED] category widget can not display inline in v3.4 duping812 New Versions, & Updating 5 Jul 11, 2009 11:10 AM
[SOLVED] Page Menu Sub Menus of Equal Width Craig Mattice Page & Category Menu Bars 4 Jun 17, 2009 03:46 AM
Disply posts in all three columns-- plus, ideally, a widget or two, too? petevannuys Sidebars & Widgets 2 Jun 11, 2009 06:51 PM
Changing a widget display from block to inline (Twitter Text Widget) Flur Sidebars & Widgets 2 May 7, 2009 11:45 AM


All times are GMT -6. The time now is 02:01 AM.


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