I was using the following code in WP 2.0.7. I've upgraded to 2.7 and the code doesn't work any more, as I no longer get any categories diplayed. There aren't any errors I can see. Here's my blog: http://www.cygen.com/blog/. You can see Categories on the right side under Pages. All of the main categories appeared there. Clicking a main category allowed sub categories to appear under it. Any suggestions on what could have broken?
<!-- start expand categories -->
<li>
<h2>Categories</h2>
<ul>
<?php
$categories = $wpdb->get_results("SELECT * FROM $wpdb->categories WHERE category_count > 0 ORDER BY cat_name DESC"); // query database for categories with at least one post;
$a = 1;
foreach($categories as $category) : // start loop to display category list
?>
<li>
<a href="<?php echo get_category_link($category->cat_ID); ?>">
<?php if (!is_category() || is_page() || $category->cat_ID === $cat){
echo $category->cat_name;}
else { echo"<font color=939392>" ;
?>
<?php echo $category->cat_name; ?>
</font>
<?php } ?>
</a>
(<?php
echo $category->category_count;
?>)
<?php /*echo is_category(); ?> <?php echo $category->cat_ID; ?> <?php echo $cat; */ ?>
<?php
if( is_category() && ($category->cat_ID === $cat) ) : // current category query is same as category presently in the loop
?>
<ul>
<?php
$a = 1;
$catq = new WP_Query("cat=$cat&showposts=-1"); // query posts from current category
while($catq->have_posts()) : $catq->the_post(); // start posts in category loop
?>
<li>- <a href="<?php the_permalink(); ?>">
<?php
if (($a % 2) == 1)
{ echo "<font color=3366ff>" ;}
if (($a % 2) == 0)
{ echo "<font color=ff0000>" ;}
$a = $a + 1;
?>
<?php the_title(); ?></a> </li>
<?php
endwhile; // end posts in category loop
?>
</ul>
<?php endif; // end current category query test ?></li>
<?php endforeach; // end loop to display category list ?>
</ul>
<!-- stop expand categories -->