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 🙂
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.