Created
September 4, 2014 02:15
-
-
Save dirtystylus/35ecf8ca3bf2341d7ab9 to your computer and use it in GitHub Desktop.
ACF with Flexible Content Field
This file contains hidden or 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 | |
/** | |
* @package modularcontent | |
*/ | |
?> | |
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> | |
<div class="entry-content"> | |
<?php | |
// check if the flexible content field has rows of data | |
if( have_rows('flexible_content') ): | |
// loop through the rows of data | |
while ( have_rows('flexible_content') ) : the_row(); | |
if ( get_row_layout() == 'image_text_overlay' ): ?> | |
<section class="text-overlay"> | |
<h1><?php the_sub_field('overlay_text'); ?></h1> | |
<?php $background_image = get_sub_field('background_image'); ?> | |
<img src="<?php echo $background_image['url']; ?>"> | |
</section> | |
<?php elseif (get_row_layout() == 'image_and_text_block' ): ?> | |
<section class="text-centered"> | |
<?php $featured_image = get_sub_field('featured_image'); ?> | |
<img src="<?php echo $featured_image['url']; ?>"> | |
<section class="text-block"> | |
<?php the_sub_field('description_text'); ?> | |
</section> | |
</section> | |
<?php elseif (get_row_layout() == 'callout_blocks' ): ?> | |
<?php if( have_rows('block_collection') ): ?> | |
<section class="text-callout"> | |
<?php while( have_rows('block_collection') ): the_row(); ?> | |
<?php $block_image = get_sub_field('block_image'); ?> | |
<section class="text-callout-block"><h1><?php the_sub_field('block_text'); ?></h1><img src="<?php echo $block_image['url']; ?>"></section> | |
<?php endwhile; ?> <!-- block collection while --> | |
</section> | |
<?php endif; ?> <!-- block collection if --> | |
<?php endif; ?> | |
<?php endwhile; ?> | |
<?php endif; ?> | |
</div><!-- .entry-content --> | |
</article><!-- #post-## --> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment