Home › Forums › General Issues › Update_field() don't work correctly with terms › Reply To: Update_field() don't work correctly with terms
You are setting a custom field on a term. For this you need to include the taxonomy as part of the $post_id. I have altered the update_field() call of your code
function my_create($term_id, $tt_id, $taxonomy) {
// gets term_data for Post
$term = get_term($term_id, 'interpret');
// Create the Post and Save ID to $post_id
$post = array(
'post_title' => $term->name,
'post_content' => $term->slug,
);
$post_id = wp_insert_post($post);
// if Post was created
if ($post_id) {
// get Post by ID
$link_to = get_post($post_id);
// Post->ID
$link = $link_to->ID;
update_field('field_558e8544d5660', $link, 'interpret_'.$term_id);
}
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.