andru26
3/30/2017 - 11:10 PM

Advanced Custom Fields Template

Advanced Custom Fields Template

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>

	<div class="entry-content orange-case-study">

		<?php
			
			if( have_rows('orange_cases_modules') ):						
				while( have_rows('orange_cases_modules') ) : the_row();


					if( get_row_layout() == 'intro_section' ): 
						$full_background_image = get_sub_field('full_background_image');
						$right_side_image = get_sub_field('right_column_image');
						$case_logo = get_sub_field('case_logo');
					?>

						<?php if($full_background_image == 0): ?>
							<section class="intro-section -intro-two-columns">
								<div class="vertical_align">
									<div class="grid_1-2 grid_1-md">
										<div class="intro-left-column">
											<img class="case-logo" src="<?php echo $case_logo['url']; ?>">
											<h2>Challenge</h2>
											<p><?php the_sub_field('challenge_text'); ?></p>
										</div>
									</div>
									<div class="grid_1-2 grid_1-md">
										<div class="intro-right-column">
											<img src="<?php echo $right_side_image['url']; ?>">
										</div>
									</div>
								</div>
							</section>		
						
						<?php else: ?>	

							<section class="intro-section -intro-full-bg" style="background-image:url(<?php echo $right_side_image['url']; ?>);">
								<div class="intro-container">
									<div class="vertical_align">
										<div class="grid_1-2 grid_1-md">
											<div class="intro-left-column">
												<img class="case-logo" src="<?php echo $case_logo['url']; ?>">
												<h2 class="white">Challenge</h2>
												<p class="white"><?php the_sub_field('challenge_text'); ?></p>
											</div>
										</div>
										<div class="grid_1-2 grid_1-md">
											<div class="intro-right-column invisible">
												<img src="<?php echo $right_side_image['url']; ?>">
											</div>
										</div>
									</div>
								</div>
							</section>				
						<?php endif; ?>

					<?php endif; ?> <!-- endif intro-two-columns -->


					<?php if( get_row_layout() == 'full_width_slider' ): ?>
						<section class="slider-section">
							<div class="full-width-slider">
								<?php if( have_rows('slider_content') ): 
									while( have_rows('slider_content') ) : the_row();
										$slider_image = get_sub_field('slider_images');
								?>
									<div class="slide">
										<img src="<?php echo $slider_image['url']; ?>">
									</div>
									<?php endwhile; ?>
								<?php endif; ?>

							</div>	
						</section>
					<?php endif; ?> <!-- endif full_width_slider -->


					<?php if( get_row_layout() == 'content_image' ): ?>
						<section class="content-image">
							<?php $image = get_sub_field('image') ?>
							<img src="<?php echo $image['url']; ?>">
						</section>							
					<?php endif; ?> <!-- endif content-image -->


					<?php if( get_row_layout() == 'case_features' ): ?>
						<?php 
							$insight_text = get_sub_field('insight_text');
							$solution_text = get_sub_field('solution_text');
							$result_text = get_sub_field('result_text');
						?>
						<section class="block case-features light-grey-bg">

								<div class="grid">
									<div class="grid_2-3 grid_1-xs">
										<h2>Insight</h2>
										<p><?php echo $insight_text; ?></p>
										<h2 class="_mg-t-lg">Solution</h2>
										<p><?php echo $solution_text; ?></p>
										<h2 class="_mg-t-lg">Result</h2>
										<p class="bigger"><?php echo $result_text; ?></p>
									</div>
								</div>
								
						</section>						
					<?php endif; ?> <!-- endif case_features -->



					<?php if( get_row_layout() == 'youtube_video' ): ?>
						<?php $video_url = get_sub_field('video_url') ?>

						<section class="content-video">
							<div class="responsive-video aspect-16by9">

								<iframe width="560" height="315" src="https://www.youtube.com/embed/<?php echo youtube_id_from_url($video_url); ?>?rel=0" frameborder="0" allowfullscreen></iframe>

							</div>
							
						</section>							
					<?php endif; ?> <!-- endif content-video -->


				<?php endwhile; ?>
			<?php endif; ?>

		</div><!-- .entry-content -->



	<footer class="entry-footer">

		<?php edit_post_link( __( 'Edit', 'twentyfifteen' ), '<span class="edit-link">', '</span>' ); ?>

	</footer><!-- .entry-footer -->



</article><!-- #post-## -->
$value = get_field( "text_field" );

if( $value ) {
    echo $value;
} else {
    echo 'empty';
}