View Single Post
Old 04-12-2012, 03:55 AM  
Brujah
Beer Money Baron
 
Brujah's Avatar
 
Industry Role:
Join Date: Jan 2001
Location: brujah / gmail
Posts: 22,157
This should display your categories, in column lists of any specified amount. I've told it to display 3 columns at bottom. If you want it to also link to them, let me know.

Code:
function columnize_categories ( $columns = 5 ) {

	$wp_categories = get_categories( array( 'hide_empty' => 0 ) );

	$categories = array();

	$per = ceil( count( $wp_categories ) / $columns );

	$i = 0;

	while ( $cats = array_splice( $wp_categories, 0, $per ) )
	{
		$categories[$i++] = $cats;
	}

	$output = '';
	foreach ( $categories as $list ) 
	{

		$output .= '<ul>';

		foreach ( $list as $item )
		{
			$output .= sprintf( '<li>%s</li>', $item->name );
		}

		$output .= '</ul>';
	}

	return $output;
}

echo columnize_categories(3);
__________________
Brujah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote