In this quick tutorial I’m using Advanced Custom Fields (ACF) repeater fields to turn out an array of photos and text that link to PDF files (brochures)… and I’m using the genesis grid settings to lay them out nicely (by adding class=”one-third” to the list items). The thing is, for the genesis grid to work you have to add a class of ‘first’ on the first list item in every row as well… so I need to set up a counter to count the list items and add a class to the first and every third … Check it out.
Here’s how I set up the ACF repeater fields
Field Group = aa_brochures
Name = name_of_brochure
Link = link_to_brochure
Image = brochure_image
PDF Size = pdf_size
The code is set up to output all of the fields above, wrapped up in the requisite HTML code that adds the individual items in an Unordered List, and each list item is being assigned a class of one-third (according to the genesis grid already in the theme), but where I was getting stuck was in adding in that first class to the first and every third item.
I did some research and found lots of bits that showed me part of the answer, and so after a fair bit of trial and error, I figured it out…
Follow through the comments in the code below, you should be able to make it out.