Home › Forums › Add-ons › Flexible Content Field › Flexible – Add code to last row entry › Reply To: Flexible – Add code to last row entry
I was able to solve this by finding the total amount of rows in your field by using get_field_object
.
In your code, after if( have_rows('cm_content') ):
try this:
$field_object = get_field_object('cm_content');
$total_rows = count($field_object['value']);
Then you can test for it with an if statement:
if($counter == $total_rows ){
// this is the last one!
}
Cheers,
Andre
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.