Developing software in the Real World

post2cat doesn't exist after upgrading WordPress

Note to help anyone else who has the same problem!

If you are a “little behind” the times when you upgrade you WordPress installation, you may see errors like this:

WordPress database error: [Table ‘xxx.wp_post2cat’ doesn’t exist]
SELECT cat_ID AS ID, MAX(post_modified) AS last_mod FROM wp_posts p
LEFT JOIN wp_post2cat pc ON p.ID = pc.post_id
LEFT JOIN wp_categories c ON pc.category_id = c.cat_ID
WHERE post_status = ‘publish’ GROUP BY cat_

This is because the tables used for storing categories has been changed and the old ones (wp_post2cat and friends) have been deleted and you have some old code in a plugin or your theme that uses it.

In my case it was this Google Sitemap Generator Plugin which was updated back when WordPress 2.1 was released, so the fault is clearly all mine! One thing that was interesting is that the plugin page within the WordPress admin system didn’t tell me that I needed to upgrade that plugin, but it did tell me about others.

3 thoughts on “post2cat doesn't exist after upgrading WordPress

  1. Thanks. In my case, it was the "posts by author' plugin, v0.9. Found it by brute-force process of elimination. Shut off all plugins and turn 'em all back on one at a time until the problem comes back.

Comments are closed.