I have the below code which creates a taxonomy like its supposed to and updates the post field with the value the first time around. But when i have 2 posts that need the same taxonomy, the code does not insert it.
$make_term = get_term( $make, 'car_make' );
if (!empty($make_term)) {
wp_set_object_terms($post_id, $make_term['term_taxonomy_id'], 'car_make');
} else {
$make_tax = wp_insert_term($make, 'car_make');
if ( ! is_wp_error( $make_tax ) && ! empty( $make_tax['term_taxonomy_id'] ) ) {
wp_set_object_terms($post_id, $make_tax['term_taxonomy_id'], 'car_make');
}
}
Does anyone have any ideas please?