Distance Debugging Logo

I noticed some people winding up here because they searched for "WordPress 2.1" and "broken" and "Tiga" (the theme that I adapted for my site) or some combination of those terms. I wanted to provide a slightly more detailed explanation of what I did to fix it. In the Tiga theme, the links list is generated by a foreach that loops over the links, printing them out in category blocks. The problematic call in Wordpress 2.1 is the one that assigns the original variable to iterate over:

$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->linkcategories");

As I mentioned before, linkcategories no longer exists, so instead you need to query the categories table.

$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->categories");

Except if you do that, you get all of your post categories showing up as well. So you want to filter on only the categories that contain links and that was the tricky part. By looking at the MySQL table structures that are printed in the WordPress Codex, I noticed that there is a link_count field. I changed the query to filter on anything that has a link_count > 0, like this:

$link_cats = $wpdb->get_results("SELECT cat_id, cat_name FROM $wpdb->categories WHERE link_count > 0");

That did the trick, and it doesn't suffer from the potential problems that I described in the original post where I was filtering on link_id. If this helps you, or if you have a better solution, would you mind leaving a comment? I'll eventually post this somewhere more permanent if it seems to be helping people. Thanks!