Support

Account

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

  • That’s what I thought. I must have done something wrong in the code. This is the code with the if statement. Can you see why it doesn’t hide when empty?
    Thanks
    Rob

    $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($file){
    	$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>';
    endif;