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

  • i’ve searched a bit and extend my code to this:

    function Taxonomy_List_Save( $post_id ) {
    
    	if is_tax( 'list' ) {
    		
    		$PostList = get_field('downloads_listing', $post_id);
    		
    		if( $PostList ) {
    			foreach( $PostList as $post) { 
    				setup_postdata($post);
    				wp_set_post_terms( $post_id, 'TaxonomyTermName', 'list', true );
    			} 
    			wp_reset_postdata();
    		}
    		
    	}
    
    }
    
    add_action('acf/save_post', 'Taxonomy_List_Save', 15);

    can you fix the code for me please? or give me hint on what’s missing ?