Support

Account

Home Forums Add-ons Repeater Field Display content if Repeater Field is empty Reply To: Display content if Repeater Field is empty

  • I finally got it! I think I wasn’t declaring my variables clearly enough.

    $row = get_field( 'document' );
    $first_row = $row[0];
    $first_row_file = $first_row[ 'file' ];
            
        if( $first_row_file ) :
            
            		$download = '<div>Available!<div>This document is ready for download.</div></div>' ;
            
            				echo $download;
        
        else :
            		
            		$unavailable = '<div>Unavailable!<div>This document isn\'t ready yet. Please check back later.</div></div>' ;
            
            				echo $unavailable;
        
        endif;

    Now I can add more sophisticated content (like a download button) to display when there is a file to download, and a helpful message when there isn’t.