Home › Forums › Add-ons › Flexible Content Field › Flexible content wrong order › Reply To: Flexible content wrong order
There are in the order that you’re code says they should be, you’re looping through and first showing all the text layouts, then the images and then the videos. If you want to show them in order then all of your if statements need to be inside a single loop.
<?php
if (have_rows('post_content')) {
while (have_rows('post_content')) {
?>
<div>
<?php
the_row();
$layout = get_row_layout();
if ($layout == 'layout_text') {
// code to show text content
} elseif ($layout == 'layout_image') {
// code to show image content
} elseif ($layout == 'layout_video') {
// code to show video content
} else {
// code to do something else
}
?>
</div>
<?php
} // end while
} // end if have_rows
?>
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.