0


I'm using wp_insert_termto add a custom taxonomy like this:

wp_insert_term(
     $_POST['city'], // the term 
     'property-city', // the taxonomy
     array(
         'description'=> $_POST['city'],
         'slug' => $_POST['city']
     )
);

It does the job, but it doesn't link this term to a certain post ID. Thus, my questions are: what does wp_insert_term do specifically? Does it just insert the term? If so, how can I link this term to a specific post ID?

1

Yes, wp_insert_term() only creates the term. To assign the term to a post use wp_set_object_terms()

wp_set_object_terms( $object_id, $terms, $taxonomy, $append ); 
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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