Home › Forums › Add-ons › Repeater Field › ACF Repeater max 6 items display inside table › Reply To: ACF Repeater max 6 items display inside table
Hi Finally figured it out. I realized that mistyped repeater sub name. Anyway since it’s only 6 items, for now this is my solution. Thank you for helping to start!
<?php
$row_html = array();
while(have_rows('repeater')) {
the_row();
$index = get_row_index();
$row_html[$index] = get_sub_field('repeatersub');
}
$count = count($row_html);
if($count==1) {
echo 'Im 1';
}
elseif($count==2){
echo 'Im 2';
echo $row_html[2];
echo $row_html[1];
}
elseif($count==3){
echo 'Im 3';
echo $row_html[3];
echo $row_html[1];
echo $row_html[2];
}
elseif($count==4){
echo 'Im 4';
echo $row_html[4];
echo $row_html[1];
echo $row_html[2];
echo $row_html[3];
}
elseif($count==5){
echo 'Im 5';
echo $row_html[2];
echo $row_html[4];
echo $row_html[3];
echo $row_html[5];
echo $row_html[1];
}
elseif($count==6){
echo 'Im 6';
echo $row_html[5];
echo $row_html[6];
echo $row_html[3];
echo $row_html[2];
echo $row_html[1];
echo $row_html[4];
}
else {
echo 'None';
}
?>
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.