• I am trying to do a custom modification and I am trying to find where the assignments for the categories are stored.
    In wp_posts I don’t see any table that mentions categories.
    If I want to manually from phpMyAdmin assign a post to a category, where would I do it from?
    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • categories, tags and link categories are stored in wp_terms table

    wp_term_taxonomy shows if this is a pos category, a tag or link category.

    wp_term_relationships assigns a post to a category.

    Categories, tags, and many other things are defined under the wp_terms table. A term will have a name, slug, and term_group. The term_id of the term table is in relation to the wp_term_taxonomy table. Which I believe is the description of what the term is and how many posts in the category (for example). In this table is a term_taxonomy_id which is in relation to wp_term_relationships table to link the post with the term by storing the post ID from wp_posts in the object_id of wp_term_relationships.

    So:

    wp_posts -> wp_term_relationships -> wp_term_taxonomy -> wp_terms

    Thread Starter marcnyc

    (@marcnyc)

    Great, thanks for your help!

    So if I created a category whose id is 8 and I want to assign a post to that category, all I have to do is create a new row in wp_term_relationships with the object_id set to the id of the post and term_taxonomy_id set to 8, is this correct?

    correct!

    Thread Starter marcnyc

    (@marcnyc)

    Great thanks rahulsonar…
    So my query would be this?
    'INSERT INTO wp_term_relationships ( object_id, term_taxonomy_id ) VALUES ( '.$id.',8 );'
    or do I need to enter it like this?

    'INSERT INTO wp_term_relationships ( object_id, term_taxonomy_id ) VALUES ( '.$id.','8' );'

    'INSERT INTO wp_term_relationships ( object_id, term_taxonomy_id ) VALUES ( '.$id.','8' );'

    8 should be in single quote..

    just for you reference:

    If you add a new post using a query, there is already a function available: wp_insert_post

    Using this function, you can assign categories at the time of adding post.. ??

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘which WP table contains category assignments?’ is closed to new replies.