Support

Account

Home Forums Add-ons Repeater Field ACF and CSS Grid? Reply To: ACF and CSS Grid?

  • “It doesn’t work” could mean anything. It’s clear that something doesn’t work because otherwise you wouldn’t be posting here. But please be more specific as to what exactly isn’t working. What is the output of the code? Is it not printing the values at all? Or perhaps it’s not even the PHP but an error in the CSS? Look at the output source code and see if it prints anything for the_sub_field('column_start'); etc. If that’s all working then the error is in the CSS itself.

    I’m going to look over the fact that CSS should at least go into the header of the HTML document, not in the body, but definitely you need to address each image in the repeater individually (as in your second example) because otherwise the last value that is printed will style all images. But you can actually get the current row index inside a has_rows() loop with get_row_index(); no need for the incementing counter variable.

    Now, I’m not too experienced with CSS grid yet, as I’ve mostly avoided it for reasons of browser support, but I’m skeptical about the row and column placement properties in combination with auto-fill columns and a fixed number of rows. If the user specifies to place the image in column 100 and row 10, how is that going to work with the specification of the grid template rows and columns? I think therein lies the actual problem; it’s not an ACF repeater issue.