Skip to content

Instantly share code, notes, and snippets.

@barbwiredmedia
Last active August 29, 2015 14:01
Show Gist options
  • Save barbwiredmedia/320f4c267a290e9895ac to your computer and use it in GitHub Desktop.
Save barbwiredmedia/320f4c267a290e9895ac to your computer and use it in GitHub Desktop.
ACF advanced custom fields select in a repeater field to choose content layout or, anything else, within a wordpress page.
<?php if (get_field('page_content_repeater')) { ?>
<?php while (the_repeater_field('page_content_repeater')): ?>
<?php
/* Pull from users select choice in ACF */
$choice1 = 'string_1';
$choice2 = 'string_2';
?>
<?php if (get_sub_field('your_selection_field') === $choice1) { ?>
<!--Your Content-->
<?php } elseif (get_sub_field('your_selection_field') === $choice2) { ?>
<!--Your alternate Content-->
<?php } ?>
<?php endwhile; ?>
<?php } else { ?>
<?php the_content(); ?>
<?php } ?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment