Created
August 21, 2016 10:58
-
-
Save mwangepatrick/28b1ba111589315f087efbfc495c022a to your computer and use it in GitHub Desktop.
Cloning a flexible field with cloned fields inside
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
<!-- testing flexible clone field --> | |
<?php | |
// check if exists | |
if( have_rows('flexi_layouts_layout_elements') ): | |
/* load the cloned field group*/ | |
$flexcontent = get_field('flexi_layouts_layout_elements'); | |
//dump the data to verify the correct layout is returned | |
//var_dump($flexcontent); | |
// loop through the rows of data | |
while ( have_rows('flexi_layouts_layout_elements') ) : the_row(); | |
if( get_row_layout() == 'latest_posts' ): | |
var_dump($latest_post_values = get_sub_field('latest_posts')); //tested and works to show an array of all the custom field values inside the layout. | |
//you can access the specifics field from the array as below. | |
echo $latest_post_values["number_of_posts_to_display"]; | |
elseif( get_row_layout() == 'paypal_forms' ): | |
the_sub_field('paypal_forms'); | |
endif; | |
//you can do this for the other layouts | |
endwhile; | |
endif; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment