8/18/2017 - 4:08 PM

ACF - Show content only if there is content

Two simple examples of only showing acf if there is content to show.

<!-- only show ACF SECTION if there are rows of content to show -->
if( have_rows('video') ): ?>
<div class="section" style="padding: 50px 0; background: rgba(211,211,211,0.31);">
	<div class="wrap v-wrap">

			// loop through the rows of data

				while ( have_rows('video') ) : the_row(); ?>

				<div id="vid-left"><?php the_sub_field('video_link'); ?></div>

				<div id="vid-right"><h2><?php the_sub_field('video_blurb'); ?></h2>
				<?php the_sub_field('video_text'); ?></div>

				endwhile; ?>
			</div><!-- End Wrap -->
		</div><!-- End Section -->
<!-- only shows ACF FIELD if there is contenty entered into the field -->
<!-- this example is showing the title if a title has been entered into the field 'career_outcomes_title'. -->
<div id="career-outcomes" class="section">
	<div class="wrap">
		<?php if( get_field('career_outcomes_title') ): ?>
			<?php echo get_field('career_outcomes_title'); ?>
			<?php endif; ?>
			<?php get_template_part('partials/careers2'); ?>
			<?php the_field('outcomes_text'); ?>