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 - 1 through 15 (of 100 total)
  • spencerp
    Member

    @spencerp

    Also, another reason for DB errors spitting out with themes, is because alot of the themes aren’t updated to the new 2.3 code! The original themes are using OLD CODE in them, resulting in Database Errors showing on blogs… Example here.

    Oh yeah, in case this was overlooked before, I made up a theme compatibility list for 2.3…
    http://codex.wordpress.org/Themes/Theme_Compatibility/2.3

    For adding tags to your themes, view this guide.

    guxo
    Member

    @guxo

    how can i upgrade my theme manualy?
    what functions do i need to rename to get my theme compatible with wp2.3?

    spencerp
    Member

    @spencerp

    I’m not sure what theme you’re using, nor do I know how it’s coded really. Only thing I can suggest, is, look through the prepackaged Default and Classic themes that came with your WordPress 2.3 download, and see how things were done in there… Unless someone else knows more, I’m not sure?

    guxo
    Member

    @guxo

    i create a table named wp_categories, create a 3 values: cat_id, cat_name and link_count.

    the error disappear.
    is this getting me troubles in the future?

    guxo, this is not a solution. the error is gone, but the table is empty, so the plugin, themes, etc who want access it will fail…

    guxo
    Member

    @guxo

    what’s the wp_categories funcionality? what’s used for?

    foolswisdom
    Moderator

    @foolswisdom

    guxo, for categories, your theme has to be updated to use the new taxonomy tables instead.
    http://codex.wordpress.org/index.php?title=Version_2.3:New_Taxonomy

    10cplay
    Member

    @10cplay

    I’m getting the same

    Table ‘wordpress.wp_post2cat’ doesn’t exist

    I don’t see a fix above… anybody got a clue on this one?

    It’s ok saying the theme is written from old code… but is the fix..what the NEW code we should be putting in.

    Very frustrating.

    spencerp
    Member

    @spencerp

    Old code as in this example here. The code is querying for tables that were removed during/after upgrade from 2.X versions to 2.3.

    Themes in general will need to be tweaked, and searched through for such “old code” to replace it with new query calls. Which I believe “foolswisdom” was pointing out above there. I’m not a PHP/MySql database Guru, so I’m only throwing out my speculations.

    guxo
    Member

    @guxo

    I’m sorry if I’m quite boring, but i take 3 month to find my actual template.. so i won’t let anyone take it from me!!!!!!!!!!!!!!!!!
    looooool
    can i change all old terms with the new table terms?
    if i left the wp_category empty what’s going to happen? does my posts disappear? i don’t use the tags system.. bu i still use the categories.. will something with categories system fail?

    tks for you patience.

    Moderator Samuel Wood (Otto)
    Keymaster

    @otto42

    It’s ok saying the theme is written from old code… but is the fix..what the NEW code we should be putting in.

    We can’t tell you that, because we don’t know what the old code actually does. You haven’t told us what the old code actually *is*, have you?

    What color is my hat? You can’t tell me, because you haven’t seen my hat.

    Start a new thread. Post the section of your theme that is not working anymore. Maybe somebody can help you fix it. Maybe not. But just getting frustrated doesn’t fix the issue.

    George
    Participant

    @george71

    Okay why is the new version 2.3 advertised as most themes are not compatible?

    Now if I would use the classic theme this message should not appear right. But I do have a database error.
    Do I have another problem here?

    WordPress database error: [Table ‘wordpressdb.en_terms’ doesn’t exist]

    http://www.georgelangenberg.com/blog

    mission
    Member

    @mission

    That is a good question george. I think, most of wp users do not use the default or classic theme.
    I just upgraded to 2.3, than got the error message:
    WordPress database error: [Table ‘mission.wp_categories’ doesn’t exist]
    SELECT COUNT(*) FROM wp_categories
    My only luck was, that I made a db backup, so I did put back 2.2.2. I think Im gonna wait for a while with this upgrading to 2.3…

    George
    Participant

    @george71

    I will do the same tomorrow, Mission. I also made a backup of the database. Where cn I download 2.2 ( I have over written those files).
    Damn this version! Upgrading used to be smooth. Now I have a broken blog running. 2.3 = not recommendable for non-coders (like me).

    Moderator Samuel Wood (Otto)
    Keymaster

    @otto42

    Okay why is the new version 2.3 advertised as most themes are not compatible?

    We don’t have any information on how many themes are compatible.

    A well-written theme would be perfectly compatible. But a theme doing its own SQL queries like you’re talking about probably would not.

    There is no circumstance I can think of that a theme should actually make its own SQL queries.

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