Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have this little code to insert posts via custom form:

 $post = array(
     'post_author' => 1,
     'post_title' => 'my title,
     'post_content' => 'my content',
     'post_category' => array(3),
     'post_type' => 'post',
  );

if ( $post_id = wp_insert_post( $post ) ){
    echo 'post added!';
 }

but now I need to insert the last $post_id to term_relationships table,

basic scheme of term_relationships:

object_id | term_taxnomy_id | term_order
-----------------------------------------

Wordpress have a function to update that table?, or I need to build a custom query?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

Check this wp_set_object_terms().

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.