While upgrading some outdated sites to the latest version of WordPress (currently 2.3.3), I ran across this error:
WordPress database error: [Table 'DB_NAME.wp_terms' doesn't exist]
When I ignored the error and continued to the admin panel, I noticed that there were no categories listed, and all the posts were set to the “uncategorized” category (though even this was not listed on the Manage -> Categories page).
The reason for this error is that WP 2.3.x does not use the wp_categories table; it uses wp_terms and wp_terms_taxonomy instead. The upgrade script is supposed to move the data from the former to the latter, but something was preventing it from doing so successfully.
A search of the WordPress codex revealed some important reminders, but no help:
- Always back up your database before attempting an upgrade
- Always disable all plugins before attempting an upgrade
- Always revert to the default “Kubrick” theme before attempting an upgrade (because many themes now contain custom functions that can interfere with the upgrade process)
Fortunately, I’d done backups, as I always do. However, I must admit to being somewhat spoiled with WordPress upgrades, as this is the first significant difficulty I’ve ever encountered with an upgrade (other than incompatible template tags and plugins). This is a chilling reminder that, no matter how well things have gone in the past, doing a backup is NOT optional; it’s essential.
After trying everything I could think of, I recalled a forum post that suggested commenting out (or deleting) these two lines in the wp-config.php file:
define('DB_CHARSET', 'utf8');
define('DB_COLLATE', 'utf8');
You can comment them out by preceding them with two forward slashes:
//define('DB_CHARSET', 'utf8');
//define('DB_COLLATE', 'utf8');
Certain earlier versions of WP shipped with these lines, though you may not have them at all.
I restored my database from the backup, used PHPMyAdmin to deactivate all the plugins and to set the theme to ‘default’, and ran the upgrade script again (by visiting mysite.tld/wp-admin).
This did it, and I was able to re-activate my plugins and theme. Problem solved.
Share This
WordPress 2.3 quietly introduced a powerful new feature that had previously only been available using plugins: tagging.
There are several ways to list your tags:
- Before or after each post, so people can click a tag to see other posts you’ve tagged the same way
- In a tag cloud in your sidebar
- On a tag archive page
I’ve found that tag archive pages are indexed very well by search engines, so I highly recommend using tags. But how should you use them, and how should they relate to WordPress categories?
As Lorelle said several years ago, tags are like a blog’s index, and categories are like the table of contents. Tags are great for SEO, but you don’t want to list a zillion of them in your sidebar; you want a concise list of categories.
It’s fine to have a zillion tags, but they’re better listed in a tag cloud or on an archive page. With that in mind, let’s look at how tags can become a part of your blog.
Listing the Tags for Each Post
Most WordPress themes have a post metadata section either before or after the body of the post, which includes the date, author, and comment link. This is a great place to display the tags for that post.
In this section, you can add
<?php the_tags('Tags: ', ', ', ' | '); ?>
to display a comma-separated list of the post’s tags, followed by a | mark. The parameters for this function are, respectively, what goes before the tags, what separates the tags, and what goes after the tags. Full documentation for this template tag (WP Codex)
Since tags are likely to make the post metadata section take up more than one line, make sure your theme still looks good if this section is several lines long; for example, some themes don’t leave enough linespacing because the theme author assumes it’ll only be one line long.
Since this tag applies to a specific post, it must be in the loop, not in the sidebar, header, or footer.
Listing Tags in a Sidebar Cloud
A tag cloud is a great way to visualize the topics you blog about, because the size of each tag is proportional to the number of times you’ve used it. This may not be immediately obvious on a new blog, but if you have 1,000 posts, and 800 of them are about horses and only 100 are about fish, the “horse” tag will be much bigger than the “fish” tag (assuming you’ve tagged your posts).
Here’s the function to display the tag cloud:
<?php wp_tag_cloud(''); ?>
You can put this tag in the sidebar or footer of your site, but don’t put it in the loop.
You can customize the minimum and maximum size of the items in the tag cloud, as well as how many to display and how to sort them. Full documentation for this template tag (WP Codex)
Displaying Tags on a Tag Archive Page
If you have tons of tags and you want to display them all in one place, but not on the main page of your blog, you can create a tag archive page. Here’s how.
- Make a copy of your single.php or index.php template, and name it something like “tag-archive.php”
- At the top of your tag archive template, insert this:
<?php
/*
Template Name: Tag Archive
*/
?>
- Replace everything from
<?php if (have_posts()) : ?>
to
<?php endif; ?>
(aka The Loop) with the <?php wp_tag_cloud(); ?> function. You can download a Kubrick-compatible tag archive template here.
- Upload the new template file tag-archive.php to your theme folder.
- Create a new page and call it something like “Tag Archives”. Under Page Template in the sidebar, select the new template you created. Leave the body of the page blank, and publish it.
- Make sure you link to the new page in your navbar or sidebar so people can find the tag archive page
Converting Categories to Tags
WordPress 2.3+ also has a category-to-tag converter, which you can use for categories that don’t have very many posts in them. To use it, go to Manage -> Import, and select Categories to Tags Converter.
The converter lists all of your categories and the number of posts in each. Select the categories you want to convert using the checkboxes, and hit Convert. This will add the tags and delete the categories you select, so be selective and don’t eliminate all of your categories.
Importing Plugin Tags to WordPress Tags
If you’ve been using a tagging plugin like Ultimate Tag Warrior or Bunny’s Technorati Tags, you can convert your tags to WordPress native tags (since they’re stored in a different place in the database). The converters (including the aforementioned category-to-tag converter) are listed in the WordPress admin panel under Manage -> Import.
Share This
Everyone has their list of favorite WordPress plugins, so I thought I’d share my current list:
- Akismet - probably the best anti-spam plugin around
- ReCaptcha - a great anti-spam plugin to use when Akismet doesn’t do the job
- WP Contact Form - there are tons of variations on this plugin, but the best I’ve found is from Doug Karr
- Admin Drop Down Menus - this plugin saves me hundreds of clicks a week by converting the two-level menus in the WordPress admin panel into dropdown menus.
- WordPress Database Backup - if you use only one plugin, this should be it. Needless to say, backing up your database is crucial.
There are tons of other plugins that are useful for particular situations, but the above are my favorite general-purpose plugins at the moment.
Share This