We’ve been using this gist for years now for creating image previews for ACF Flexible Content components. Very recently it just stopped working, however. Our best guess is that it is a race condition of some sort, most likely caused by the DOM being generated in JS later. The fix…
Category: Advanced Custom Fields
Programmatically setting ACF license key
EDIT – 2022-04-12 This code doesn’t actually work. I think it did while I was testing because of some glitches elsewhere. Instead, you can now just set the constant ACF_PRO_LICENSE. You can use the following code to inject the Advanced Custom Fields Pro license key automatically:
Remove buttons from a WYSIWYG editor for a specific ACF field type
You can pretty easily customize the advanced custom fields WYSIWYG toolbars globally, however doing so on a case-by-case basis needs to be done in JS since the editing experience is so dynamic. This code is looking for a specific ACF field called step_text and sets the WYSIWYG editor to only…
Preferred WP/ACF image usage
In ACF, try to never use the_sub_field() on an image and always have ACF return an image array, especially for larger images. Calling the_sub_field() directly will bypass WordPress’s image sizing code and should only be used if you have an explicit size that designers are cropping to in Photoshop. To…