WordPress · September 27, 2007

Table ‘wordpress.wp_post2cat’ doesn’t exist – Error while upgrading to WordPress 2.3

Just today I performed an upgrade to the brand new WordPress 2.3.

Problem #1

The upgrade went without a hitch but the moment I refreshed my site I got this long error message that went like…

 WordPress database error: [Table 'wordpress.wp_post2cat' doesn't exist]
 SELECT p2c.category_id AS cat_id, COUNT(p2c.rel_id) AS numposts, UNIX_TIMESTAMP(max(p.post_date_gmt)) + '0' AS last_post_date, UNIX_TIMESTAMP(max(p.post_date_gmt)) AS last_post_date_gmt FROM wp_post2cat p2c INNER JOIN wp_posts p ON p2c.post_id=p.id WHERE (p.post_status='publish' OR p.post_status='static') AND p.post_date_gmt<='2007-09-27 11:44:24' GROUP BY p2c.category_id ORDER BY numposts DESC...

The same error kept appearing on the top of every single page. Now be aware that this new version of WordPress has a radically different table organisation. In all probability that was the cause of this error.

My first task was to disable every single plug-in I had installed. I was hoping that the error would go away immediately. It did not. After a bit of investigation I figured that even though the WP-Cache plug-in was disabled, it kept delivering the cached pages nevertheless. Deactivating it from the Plugins Panel didn’t help much. What I had to do was to go to Options > WP-Cache and disable it there. Only then did the caching stop.

The next step involved reactivating the plug-ins one-by-one and refreshing the site every time to see which plug-in was causing the error. I know it’s a painstaking task – but there’s no easy way out. Of course, you can make some well-aimed guesses, as the most likely culprit(s) are the plug-in(s) dealing with post categories, keywords, tags etc. Likewise, it didn’t take me long to catch the darned plug-in red-handed. Turned out to be Jerome’s Keywords (v2.0 beta 3). I use the Jerome’s Keywords Related Posts plug-in to display reading suggestions after each post. This plug-in in turn is dependent on Jerome’s Keywords.

As of now, I don’t think there’s any solution to this – except for deactivating the plug-in. I’ve posted a comment at the author’s site and waiting for some sort of a response.

Problem #2

As soon as I tackled the first one, a new one crept up silently and threw me off-balance again. This time the error message appeared when I tried to create a new post and save it. The screen went totally blank except for a lonely error message…

WordPress database error: [Table 'wordpress.wp_categories' doesn't exist]
 SELECT c.cat_ID AS ID, MAX(p.post_modified) AS last_mod FROM `wp_categories` c, `wp_post2cat` pc, `wp_posts` p WHERE pc.category_id = c.cat_ID AND p.ID = pc.post_id AND p.post_status = 'publish' AND p.post_type='post' GROUP BY c.cat_id...

This one wasn’t hard to diagnose as half of my plug-ins were already deactivated. I simply started rolling back the activations one-by-one and had the trouble-maker in a minute or two. This time it was Google XML Sitemaps Generator (v3.0b8). Visiting the authors site took me to a post at the support forum at WordPress.org. Seems like this version of the plug-in has some sort of a conflict with Popularity Contest. The solution is quite simple here. Simply download the new v3.0b10 of this plug-in and update it. The error message disappears right-away.

So here are two very common problems you’re going to face while upgrading to WordPress v2.3. This post is intended to help those who’re facing the same problem and groping in the dark as I was a couple of hours back.

All the best.