Support

Account

Home Forums Backend Issues (wp-admin) Update Taxonomy Field

Solving

Update Taxonomy Field

  • I am having a bit of trouble updating a custom field with a taxonomy term. Looking around the web there isnt much help.

    I create a new term which works. But then I want to update a custom field from ACF with the new term. The field I am updating is a taxonomy.

    Here is my code:

    $make_term = wp_insert_term($make, "car_make");
    update_field('field_5b435f2052447', $make_term->term_id, $post_id);

    When i go to the post, the field is not updated: http://prntscr.com/lelb1p

    I have tried this as well and it has not worked either:

    $make_term = wp_insert_term($make, "car_make");
    wp_set_object_terms($post_id, $make_term, 'car_make');

    Can anyone suggest where i am going wrong please?

  • Also wondering if you’ve found way to get custom fields in WP templates in Taxonomy. please tell me .

  • A taxonomy field holds and array of terms

    
    update_field('field_5b435f2052447', array($make_term->term_id), $post_id);
    

    your second code example will only work if you have the taxonomy field set to load and save terms.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Update Taxonomy Field’ is closed to new replies.