Created
April 19, 2015 21:06
-
-
Save Yogatopia/4e83139a14257401fa48 to your computer and use it in GitHub Desktop.
ACF
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// check if the flexible content field has rows of data | |
if( have_rows('blog_content') ): | |
// loop through the rows of data | |
while ( have_rows('blog_content') ) : the_row(); | |
if( get_row_layout() == 'image_title_content' ): | |
$title = get_sub_field('title'); | |
$img = get_sub_field('image'); | |
$content = get_sub_field('content'); | |
echo '<img src="'. $img['url'] .'">'; | |
echo '<h2>' . $title . '</h2>'; | |
echo $content; | |
elseif( get_row_layout() == 'paragraph' ): | |
$paragraph = get_sub_field('paragraph'); | |
echo $paragraph; | |
elseif( get_row_layout() == 'title_content' ): | |
$title = get_sub_field('title'); | |
$content = get_sub_field('content'); | |
echo '<h2>'. $title . '</h2>'; | |
echo $content; | |
elseif( get_row_layout() == 'video' ): | |
echo '<div class="embed-container">'; | |
$video = get_sub_field('video'); | |
echo $video; | |
echo '</div>'; | |
elseif( get_row_layout() == 'quote' ): | |
$quote = get_sub_field('quote'); | |
echo '<blockquote><p><em>'; | |
echo $quote; | |
echo '</em></p></blockquote>'; | |
elseif( get_row_layout() == 'title_content_video' ): | |
$title = get_sub_field('title'); | |
$content = get_sub_field('content'); | |
echo '<h2>' . $title .'</h2>'; | |
echo $content; | |
echo '<div class="embed-container">'; | |
$video = get_sub_field('video'); | |
echo $video; | |
echo '</div>'; | |
elseif( get_row_layout() == 'code' ): | |
$code_title = get_sub_field('code_title'); | |
$code_desc = get_sub_field('code_description'); | |
$code = get_sub_field('code'); | |
echo '<h2>' . $code_title . '</h2>'; | |
echo $code_desc; | |
echo '<code>' . $code . '</code>'; | |
endif; | |
endwhile; | |
else : | |
// no layouts found | |
endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment