Support

Account

Home Forums General Issues Update Taxonomy of posts selected by acf relation field Reply To: Update Taxonomy of posts selected by acf relation field

  • 
    function Taxonomy_List_Save( $post_id ) {
    
    	$PostList = get_field('downloads_listing', $post_id);
    	
    	if( $PostList ): 
    		foreach( $PostList as $List): // variable must be called $post (IMPORTANT) 
    			wp_set_post_terms( $post_id, $List->ID, 'list', true );
    		endforeach; 
    	endif;
        // Check if a specific value was sent.
        if( get_field('hero_image', $post_id) ) {
            // ...
        }
    }
    
    add_action('acf/save_post', 'Taxonomy_List_Save', 15);