Next time you post code please use the code button so that your code is more readable.
I’m not sure what documentation you’re referring to, I’m going to go by this as an example http://www.advancedcustomfields.com/resources/get_row_layout/
You’re using some incorrect function.
the_sub_field() echos the content of the field. To assign that value you need to use
get_sub_field(). I’ve also substitued
the_flexible_field() as shown in the example.
$quantity; $price; $color; $combine = array(); $count = 1; if (get_field('flexible_content')): while (the_flexible_field("flexible_content")): if (get_row_layout() == 'content' ): $quantity = get_sub_field('quantity'); $price = get_sub_field('price'); $color = get_sub_field('color'); $combine = $quantity.','.$price.','.$color; $count++; endif; endwhile; // output the array // you should replace this with your code to display the array echo '<pre>'; print_r($combine); echo '</pre>'; else: // no layouts found endif;
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
2022 was a big year for Advanced Custom Fields, with more capabilities, a new generation of ACF Blocks, a refreshed UI, and a new home. Our year in review post looks at advancements we’ve made and offers a glimpse of the future.— Advanced Custom Fields (@wp_acf) January 6, 2023
© 2023 Advanced Custom Fields.