rachael-portier
7/30/2019 - 4:50 PM

Conditionally Display ACF

Only display custom field if it's filled in.

	<?php if( get_field('power_source') ): ?>
	<span><b>Power Source:</b> <?php the_field('power_source'); ?></span>
<?php endif;

	if( get_field('batteries_included') ): ?>
	<span><b>Batteries Included:</b> <?php the_field('batteries_included'); ?></span>
<?php endif; 
	
	if( get_field('blade_diameter') ): ?>
	<span><b>Blade Diameter:</b> <?php the_field('blade_diameter'); ?></span>
<?php endif; 
	
	if( get_field('max_cut_depth') ): ?>
	<span><b>Maximum Cut Depth:</b> <?php the_field('max_cut_depth'); ?></span>
<?php endif; 
	
	if( get_field('track_length') ): ?>
	<span><b>Track Length:</b> <?php the_field('track_length'); ?></span>
<?php endif; 
	
	if( get_field('saw_track_included') ): ?>
	<span><b>Saw Track Included:</b> <?php the_field('saw_track_included'); ?></span>
<?php endif; ?>






<!-- ENABLE SHORTCODE -->
function specs_shortcode(){ 
	 if( get_field('power_source') ): ?>
	<span><b>Power Source:</b> <?php the_field('power_source'); ?></span>
<?php endif;

	if( get_field('batteries_included') ): ?>
	<span><b>Batteries Included:</b> <?php the_field('batteries_included'); ?></span>
<?php endif; 
	
	if( get_field('blade_diameter') ): ?>
	<span><b>Blade Diameter:</b> <?php the_field('blade_diameter'); ?></span>
<?php endif; 
	
	if( get_field('max_cut_depth') ): ?>
	<span><b>Maximum Cut Depth:</b> <?php the_field('max_cut_depth'); ?></span>
<?php endif; 
	
	if( get_field('track_length') ): ?>
	<span><b>Track Length:</b> <?php the_field('track_length'); ?></span>
<?php endif; 
	
	if( get_field('saw_track_included') ): ?>
	<span><b>Saw Track Included:</b> <?php the_field('saw_track_included'); ?></span>
<?php endif; 
}
add_shortcode('acf_specs','specs_shortcode');
?>
<!-- SHORTCODE WOULD BE [acf_specs] -->