Support » Everything else WordPress » Database not saving categories in wp_post->post_category

  • Resolved Iseemtobeaverb


    I recently checked my database under wp_posts and noticed that all of my posts have a value of 0 in the wp_category field.

    After finding this out I created a new post and checked a couple of categories for it. The post successfully shows up in the correct categories, as do all of my previous posts.

    Has anyone else had this problem?

    Any thoughts on how to resolve it?

Viewing 10 replies - 1 through 10 (of 10 total)
  • Moderator Samuel Wood (Otto)

    (@otto42) Admin

    It is not a problem. The post_category column is deprecated and is no longer used. It has not been used since pre-2.0, I believe.

    Thanks for the reply, good to know.

    Can you tell me where the database stores this info now?

    I’m having a developer work on a few things for me and he is not familiar with where these values are stored.

    Moderator Samuel Wood (Otto)

    (@otto42) Admin

    That depends on what info you are looking for…

    Categories and tags are considered to be part of a broader class of “terms”.

    The individual terms are stored in the wp_terms table.

    These terms are grouped into taxonomies (like “category” or “tag”) using the wp_taxonomy table.

    The wp_term_relationships table then associates these taxonomies with objects like posts or links.

    So, to get the category names with a particular post takes three INNER JOINs. On the other hand, if you just want a list of categories, it only takes one.

    Hi, if I could unresolve this for a little more clarification. I am importing a 1000+ records into a database made up of a dozen custom fields. Everything’s working fine, except that I’d like every new record to be listed as a MEMBER category. MEMBER is the only category and is the default.

    Since importing or even creating a new record does not automatically make them a MEMBER I’ve been trying to go into the database, using phpMyAdmin, and do it there.

    But browsing an individual record I just can’t see anywhere that the Category is registered. Is there someway to do this, ie, to make all posts be Category 1?


    Did you have any luck with this, msky? I am trying to import (using phpMyAdmin) 700 posts into a WP2.7 database, and there are nine categories. I see no way to specify what category each post should go into during the import.

    Figured it out with a little experimenting.

    When you create a category in WordPress, there will be a category ID# for the new catgory(nothing new about that, of course). Find your ID# by hovering your cursor over the category link name on the category page and check your browser’s status bar (something like

    There are three relevant tables in the database which are all updated each time you add/remove/change a category:

    — wp_terms
    — wp_term_taxonomy
    — wp_term_relationships

    In wp_terms, you’ll find a field called term_id. Each category is listed with its category # as the term_id, and these are linked with the category name and slug.

    The table wp_term_taxonomy also contains the term_id, but in this table it is linked with another field, the term_taxonomy_id, and also contains some other details.

    The third table, wp_term_relationships, contains just three fields: object_id, term_taxonomy_id, and term_order. This is the file in which you can import data to link your posts with categories.

    In my case, I export all the posts from a Joomla site and imported them to a new WordPress 2.7 site using phpMyAdmin. I then created all the categories manually, but if you have hundreds you could probably import them to the wp_terms table.

    I had previously used phpMyAdmin to export the Joomla posts to an Open Office spreadsheet, but CSV would be fine too. I opened the file in Open Office base, and changed all the Joomla category ID#s to the correct new corresponding WordPress category ID#s, and then deleted all the columns except for the post ID # and the category ID #. I saved it as CSV and used phpMyAdmin to import the file into wp_term_relationships using the “CSV using LOAD DATA” option. Bingo, all my posts were now linked to categories. This was low risk for me, as I was importing the stuff into a blank site, so if I screwed up the import, I could just delete the content from the table and try again, but that was not necessary.

    Just to reiterate: importing posts and importing category relationships are separate operations, because the category ID is not listed anywhere in the post record. It seems weird at first, but makes sense when you get your head around it.


    I’m having a problem displaying more than one category. From some of the other message boards I’ve read, I can see that other people are having a similar problem.

    I go to the admin Dashboard and open the Categories page. I can add new categories and sub-categories here, but they never show up on the blog page. I am able to edit the original (“uncategorized”) category to another name, but that is all.

    I “repaired” all of my MySQL tables, as suggested, but this didn’t help. By the way, I don’t see a wp_category table in my database (described in some older documentation), but I do see the name of my (missing) category in the wp_terms table as well as the description of the (missing) category in the wp_term_taxonomy table.

    These are the 10 tables in my MySQL database:


    I think I’m using 2.7. I installed it through the GoDaddy interface.

    Can anyone help me? Thanks !!!

    Jerry Bucknoff
    PM Best Practices

    Hi Jerry, yes you are using 2.7
    You appear to have one category, main blog.
    If other categories are saving, do they contain content, if they are empty they will not show up.
    hope you get there.

    Thanks Hedley your explanation makes a lot of sense. I have a question about importing posts perhaps you can help with – I have roughly 2,000 I need to add into my dB – the structure of the table they are in right now is identical to the default wp_posts table – however, whenever I do the sql import (which works) none show up in my admin interface – any idea why?

    Thanks in advance…

    I figured this out – user error – didn’t populate the “type” row with “post”…

    I did run into another issue though – after performing the import all of my posts show u in the dB and admin, but whenever I browse to them via the site the only portion of the post that shows up is the excerpt. It is not until I go back in the admin and “update” the ost that it shows up in full; Seems simple enough, but ding it manually fr roughly 2,000 posts will take me a month…

    Anyone run into this?

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Database not saving categories in wp_post->post_category’ is closed to new replies.