Home › Forums › Add-ons › Flexible Content Field › Flexible content need help › Reply To: Flexible content need help
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 has_sub_field()
with 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!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.