Support

Account

Home Forums Add-ons Repeater Field Hide a repeating audio field when empty Reply To: Hide a repeating audio field when empty

  • Hi @fanlokbun

    Apologies for the delay.

    You need to remove the endif; at the bottom of your code.

    This should work:

    $story_audio = '<div class="story-audio">';
    $story_audio .=  '<span><strong>Audio / Voice recordings: </br></strong></span>';
    	if( have_rows('voice') ): while ( have_rows('voice') ) : the_row();
    	$file = get_sub_field('voice_recording');
    	if(get_sub_field('voice_recording')){
    	$story_audio .='<a href="'. $file['url'].'" target="_blank">'.$file['title'].'</a></br>';
    	//if statement added from ACF - set all the logic within this
    	}
    
    	endwhile; else : endif;
    $story_audio .= '</div>';
    if (function_exists('zbp_content')) {
    		$story_audio = zbp_content($story_audio);
    }
    $content_output .= $story_audio;
    $content_output .= '<div class="story-links">';
    $content_output .=  '<span></br><strong>Links to related web content / sources: </br></strong></span>';
    	if( have_rows('sources') ): while ( have_rows('sources') ) : the_row();
    	$content_output .='<a href="'. get_sub_field('link_url').'" target="_blank">'.get_sub_field('site').'</a></br>';
    	endwhile; else : endif;
    $content_output .= '</div>';