Home › Forums › General Issues › Add class to acf fields › Reply To: Add class to acf fields
I have the same problem but on flexible layouts fields.
i would like to make some customized css for different layouts of the same repeater.
I ended up adding some jquery to get the data-layout attribute from repeater layout row and using it as css class to the very same element.
So you’ll have different classes for different repeater layouts, based on the layout name.
this is the small script I’ve done, nothing special but it works.
jQuery.noConflict()(function($){
"use strict";
$(document).ready(function() {
var layouts = $('.acf-flexible-content .layout');
layouts.each(function( key, value ) {
var section_attribute = $(this).attr('data-layout');
$(this).addClass(section_attribute);
});
});
});
Would be surely better if this classes were built in ACF PRO
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.