Home › Forums › General Issues › Update Taxonomy of posts selected by acf relation field › Reply To: Update Taxonomy of posts selected by acf relation field
in general by using this code:
function Taxonomy_List_Save( $post_id ) {
$posts = get_field('downloads_listing', $post_id);
$term_id = intval(str_replace('term_', $post_id));
if ($posts) {
foreach ($posts as $post) {
// make sure "list" is the taxonomy name and not the term name
wp_set_post_terms($post->ID, $term_id, 'list', true);
}
}
}
add_action('acf/save_post', 'Taxonomy_List_Save', 15);
in my functions.php i should be able to edit a taxonomy term (like tags) and select a post from “RelationField” of acf and by saving the tag term page the selected post should have that tag attached automatically ?
cause this is what i’m looking for and neither by term id or slug i can’t make it work with the above code.
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.