Skip to content

Instantly share code, notes, and snippets.

@Yogatopia
Created April 19, 2015 21:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Yogatopia/4e83139a14257401fa48 to your computer and use it in GitHub Desktop.
Save Yogatopia/4e83139a14257401fa48 to your computer and use it in GitHub Desktop.
ACF
<?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