Home › Forums › Add-ons › Repeater Field › Using get_post_meta as Fallback on Repeaters › Reply To: Using get_post_meta as Fallback on Repeaters
because $rows
always have the count of rows you could use:
$rows = get_post_meta( 348, 'testimonials', false ); // get number of rows (8 but in a array)
$row_count = $rows[0]; //get row number out of array (8)
$row_count--; // because first row start with 0 not 1 subtract one from row number (8-1 =7)
//now you could use $row_count to get last row (7)
echo 'testimonials_'.$row_count.'_testimonial'; //you need to replace echo by a variable and use that
Hint:
$rows--;
is short form of $rows = $rows-1;
because $rows
and better $row_count
always have the correct row number you can add/remove rows without problems
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.