Skip to content

Instantly share code, notes, and snippets.

@ajithrn
Created July 7, 2014 00:09
Show Gist options
  • Save ajithrn/16f8c67541dadc87f5b3 to your computer and use it in GitHub Desktop.
Save ajithrn/16f8c67541dadc87f5b3 to your computer and use it in GitHub Desktop.
Wordpress: ACF Flexible
<?php
// check if the flexible content field has rows of data
if( have_rows('sb_blocks') ):
// loop through the rows of data
while ( have_rows('sb_blocks') ) : the_row();
if( get_row_layout() == 'sbb_image_tile' ): ?>
<section class="sidebar-block">
<?php $sb_img = get_sub_field( 'sbbi_image' ); ?>
<a href="<?php the_sub_field( 'sbbi_url' ); ?>">
<img src="<?php echo $sb_img['sizes']['sidebar-thumb']; ?>" alt="<?php the_sub_field( 'sbbi_title' ); ?>">
</a>
</section>
<?php elseif( get_row_layout() == 'sb_content' ):
$file = get_sub_field('file');
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