PHP - Wordpress Categories...

Discussion in 'PHP' started by sitedesigner, Feb 3, 2008.

  1. #1
    What table in wordpress determines which category each post is in?

    Thank you,
    David
     
    sitedesigner, Feb 3, 2008 IP
  2. e_anka

    e_anka Member

    Messages:
    31
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #2
    Categories are kept in wp_terms and wp_term_taxonomy, and the table which combines post id with category id is wp_terms_relationships.
     
    e_anka, Feb 3, 2008 IP
  3. sitedesigner

    sitedesigner Peon

    Messages:
    578
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Ok

    I have a script that makes posts in wordpress but has nothing to define category yet.

    How would I then insert something into the wp_terms_relationships?

    Thanks!

    -David
     
    sitedesigner, Feb 3, 2008 IP
  4. sitedesigner

    sitedesigner Peon

    Messages:
    578
    Likes Received:
    5
    Best Answers:
    0
    Trophy Points:
    0
    #4
    I've got something like this right now

    $post_ID = wp_insert_post ( $post_data );
    $sql = 'INSERT INTO `rl_blog`.`wp_term_relationships` (`object_id`, `term_taxonomy_id`) VALUES (\''.$post_ID.'\', \'31\');';
    PHP:
    but I'm not quite sure how to do it because that doesnt work.
     
    sitedesigner, Feb 3, 2008 IP