How to: Sequentially Number ACF Pro Repeater Field Results in WordPress

31st January 2017

Today I really needed to sequentially number the output of a repeater field created using the Advanced Custom Fields Pro plugin. Although this is a bit of a niche requirement, I thought I’d post the result here.

My original code, used to pull through all of the images in the photo gallery I’d set up for the current post, with their alt attributes. This is the basic usage you’ll find in the documentation:

And then my revised code, which sequentially numbers these results and gives them a class of id-number.

If you want to start the sequence from a number other than 1, you can do that by changing $postnumber = 1 to any value you like. You can of course also move the output, it doesn’t have to be used to create a unique class.

Jo was completely fantastic! I’d been struggling to make a WordPress blog deisgn work and was completely stumped. I made an enquiry to Jo about some help, and she replied within 24 hours. It was easy to agree on a price for the things that needed to be done, and she had fixed everything within 48 hours of the original enquiry. I had thought my problem was too small for someone to help with it, but I was pleasantly surprised that Jo was happy to sort out the small issues with my site for an extremely reasonable fee. Throughout the process, Jo was efficient, effective and stayed in regular communication. She answered all of my questions, even the really idiotic ones, and nothing was too much trouble. The entire experience was great and I would recommend her in a heartbeat to anyone who needs help with a website project – big or small. She is, in short, superb at what she does.

(Imogen Goold)