WordPress.org

Support

Support » How-To and Troubleshooting » Solution for 2.3 database errors / wp_post2cat does not exist

Solution for 2.3 database errors / wp_post2cat does not exist

  • If you are getting a database error like this:

    WordPress database error: [Table ‘wp_post2cat’ doesn’t exist]
    SELECT p2c.category_id AS cat_id, COUNT(p2c.rel_id) AS numposts, UNIX_TIMESTAMP(max(posts.post_date_gmt)) + ‘8’ AS last_post_date, UNIX_TIMESTAMP(max(posts.post_date_gmt)) AS last_post_date_gmt FROM wp_post2cat p2c INNER JOIN wp_posts posts ON p2c.post_id=posts.id WHERE 1 = 1 AND posts.post_type = ‘post’ AND posts.post_status = ‘publish’ AND posts.post_date_gmt <= ‘2007-09-19 12:08:25’ GROUP BY p2c.category_id ORDER BY numposts DESC

    or like this:

    WordPress database error: [Table ‘wordpress.wp_post2cat’ doesn’t exist]
    SELECT c.cat_name FROM wp_post2cat p2c INNER JOIN wp_categories c ON p2c.category_id = c.cat_id WHERE p2c.post_id = 218

    or like this:

    WordPress database error: [Table ‘wordpress.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_ID

    or any other database error which contains wp_post2cat or wp_categories, you are using a plugin or theme which is not compatible with WordPress 2.3.

    Example plugins which don’t work:

    It could also be that your theme is causing this error:

    Please double check before posting that you don’t use any incompatible plugins. A list of plugins that work and which won’t work can be found at the WordPress Codex.

Viewing 15 replies - 46 through 60 (of 100 total)
  • buzz
    Member

    @buzz

    I had this error with no plugins activated. Turns out I had uploaded the wrong wp-config.php file.

    americasroof
    Member

    @americasroof

    After considerable drama I used phamyadmin to add the table back (it was not picky about field names or descriptions). That solved the problem.

    Chris_K
    Member

    @handysolo

    That solved the problem

    Well, it “masked” the problem. It’ll be back to bite you unless you figure out which theme or plugin you’re using needs to be upgraded.

    subwayblogger
    Member

    @subwayblogger

    NOTICE Google sitemap plugin does not automatically get flagged as needing to be upgraded. I had a pre 3.0 version, and the new plugin checker didnt know that there was a new one.

    As soon as I upgraded to 3.0, everything worked like butter.

    Keilya
    Member

    @fantasycrusader

    joyce and fantasy..

    http://wordpress.org/support/topic/135636?replies=5

    Much love and thanks. ^_^

    Stephanie Leary
    Participant

    @sillybean

    Otto42: well, that marks the first time Transmit has failed me on synchronization, but re-uploading wp-includes did indeed fix the problem. Thanks.

    I updated with Dreamhost’s one click install, and now I’m getting this at the very top of my page, and also in the sidebar where the categories should be:

    WordPress database error: [Table 'megatonikwp1.wp_terms' doesn't exist]
    SELECT t.*, tt.*, tr.object_id FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category', 'post_tag') AND tr.object_id IN (313, 312, 309, 306, 303, 301, 299, 298, 296, 295, 294, 293, 291, 284, 283) ORDER BY t.name ASC

    And this where categories should show up below posts:

    WordPress database error: [Table 'megatonikwp1.wp_terms' doesn't exist]
    SELECT t.*, tt.* FROM wp_terms AS t INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id INNER JOIN wp_term_relationships AS tr ON tr.term_taxonomy_id = tt.term_taxonomy_id WHERE tt.taxonomy IN ('category') AND tr.object_id IN (313) ORDER BY t.name ASC

    Plus, all my categories got deleted, and I can’t add any new ones.

    I really need to get this fixed…can any one help, and if possible tell me how I can make my theme compatible?

    demodulated
    Member

    @demodulated

    Thank goodness I knew about the forums at wordpress.org. I was THIS CLOSE (holds fingers close together) to looking for a new blog platform after getting this database error after upgrading. Luckily the forums advised me to toggle my theme and plugins and I isolated the problem as an old Google Sitemaps plugin.

    I was quite frustrated with the installation instructions. It’s a good thing I’d upgraded so many times before so the absence in the quick install guide of a recommendation to make backups was conspicuous! Why are people not recommended to make backups?? Good thing I did!!!!

    I’m also annoyed that the quick install guide didn’t advise me that some plugins are not compatible with WP2.3 so I had no idea that they could be the problem. Toggling plugins one by one revealed the issue and I was up and running in no time – after hours and hours of troubleshooting.

    Great release but terrible documentation. The poor docs nearly made me ditch WordPress forever. If I did this my first post would be advising everyone to stay far away from WordPress.

    For shame. This was a very common problem with a very easy solution, and if I didn’t think to look at the forums I never would have fixed it.

    erm, can someone please explain to me this in layman terms?

    Ultimate Tag Warrior 3.14159265 Possibly incompatible: old category table.1

    how do i fix it?

    @demodulated

    maybe it’s because you »upgraded so many times« and because you’re such a pro, that you don’t read instructions… maybe it’s because you found WordPress somewhere else…

    We’ve got information on installation and upgrading if you need it.

    Step 0: Before You Get Started

    * Just in case something goes wrong, it never hurts to have a backup. We have extensive instructions to help you out.

    what else do you need?

    Here’s how I fixed it.

    Previous code:

    <?php
    	$query = "SELECT cat_ID, cat_name, category_nicename, category_description, category_parent, category_count FROM $wpdb->categories ORDER BY cat_name";
    	$categories = $wpdb->get_results($query);
    	foreach ( $categories as $category ) {
    		echo("<div class=\"cat_num\">".intval($category->category_count)."</div><div class=\"cat_name\"><a href=\"".get_category_link($category->cat_ID)."\">".$category->category_nicename."</a></div>");
    	}
    	?>

    New code:

    <?php
    	$query = "SELECT * FROM $wpdb->term_taxonomy JOIN $wpdb->terms ON ($wpdb->term_taxonomy.term_id = $wpdb->terms.term_id) WHERE $wpdb->term_taxonomy.taxonomy = 'category' ";
    	$categories = $wpdb->get_results($query);
    	foreach ( $categories as $category ) {
    		echo("<div class=\"cat_num\">".intval($category->count)."</div><div class=\"cat_name\"><a href=\"".get_category_link($category->term_id)."\">".$category->name."</a></div>");
    	}
    	?>

    Basically, instead of grabbing the fields from the categories table, you grab anything that’s a category in the taxonomy table and look up the title in the terms table. I’m sure there’s an even smarter or more proper way of doing it (such as using the relationships lookup table) but for my simple little category link list it did the trick.

    I’m having similar woes. Here’s what I’ve been getting lots and lots of since upgrading to 2.3:

    WordPress database error: [Table ‘py.wp_post2cat’ doesn’t exist]
    SELECT post_id, category_id FROM wp_post2cat WHERE post_id IN (***)

    [I’ve substituted *** for the numbers that appear in parentheses, as they are different in each post and appear to be the post number.]

    I tried disabling all plugins. This made no difference. (I had only a few basic ones anyway.)

    I tried changing from my own custom theme to other themes. The problem didn’t change. (The only thing I had altered in my own theme was the CSS. I don’t know enough about PHP to mess with that.)

    Searches of my files didn’t turn up the code magnetbox posted, so I couldn’t change that.

    douglsmith’s Preflight plugin didn’t turn up anything in need of fixing.

    What *does* improve things temporarily is if I run the database update script (wp-admin/upgrade.php). But, oddly enough, the fix doesn’t last; the problems always return.

    I’ve cleared the cache in my browser. I’ve tried different browsers (Opera, Firefox, IE). No difference.

    In case it matters, this blog is hosted on Dreamhost. WordPress was installed through the Dreamhost panel and has been upgraded through that as well.

    Any useful advice would be gratefully received. Thanks.

    I deactivated Jerome Keyword’s Plugin. Popularity Contest latest plugin “works” now for 2.3

    It’s kinda weird. If I activate Jerome Keyword’s Plugin, the infamous wp_post2cat complains however, on other pages such as archive, category, it didn’t show.

    I just lost my tags. Sadness.

    NS Recent Posts also shows the error.

Viewing 15 replies - 46 through 60 (of 100 total)
  • The topic ‘Solution for 2.3 database errors / wp_post2cat does not exist’ is closed to new replies.