Support

Account

Home Forums ACF PRO Clear editor content depending on option Reply To: Clear editor content depending on option

  • Hi @ophie

    The repeater field will keep the subfields value until you deleted the value manually. That means using conditional logic won’t delete the value.

    As a workaround, you need to check the select value and show the right layout for the right content type like this:

    // check if the repeater field has rows of data
    if( have_rows('repeater_field_name') ):
    
     	// loop through the rows of data
        while ( have_rows('repeater_field_name') ) : the_row();
    
            // check the content type
            if( get_sub_field('content_type') == 'article' ) {
                
                // show article
                the_sub_field('article_sub_field_name');
                
            } elseif( get_sub_field('content_type') == 'background' ) {
                
                // show background
                the_sub_field('background_sub_field_name');
                
            }
            
    
        endwhile;
    
    else :
    
        // no rows found
    
    endif;

    I hope this helps 🙂