How do you fetch the last value only from the following code. At the moment, this code prints all the rows but I just need to echo the last number only. I am using a custom repeater field that allows multiple uploads so I need the $counter variable to return the last number which I can then concatenate with Documents to get say, 5 Documents.
while( have_rows('tender_docs') ): the_row(); $counter++; echo $counter . ' Documents'; endwhile; else :
Rather than printing the document number inside the while loop, you can simply print it after the while loop where you have the final count.
while( have_rows('tender_docs') ): the_row(); $counter++; endwhile; echo $counter . ' Documents'; else :