Support

Account

Home Forums General Issues update_field on newly created taxonomy term

Unread

update_field on newly created taxonomy term

  • Hi. I am trying to set a field value on a custom taxonomy term, which may be newly created. Here’s my logic:

    $client_term = get_term_by( 'name', $contact['name'], 'mp_client' );
    if ( !$client_term ) {
        $client_term = wp_insert_term( $contact['name'], 'mp_client' );
    }
    update_field( 'contact_id', $contact['id'], 'mp_client_' . $client_term->term_id );

    For some reason, update_field doesn’t save the value when the term is newly created by wp_insert_term. For existing terms, it works.
    Why is that? I’ve tried saving using field_keys, but it makes no difference.

Viewing 1 post (of 1 total)

You must be logged in to reply to this topic.