ACF apparently expands shortcodes before returning content, which means if you attempt to run it through the_content filter, any line breaks will get hit by wpautop. We fought and fought and fought, moving filter orders around, removing filters, etc., and finally decided to not fight WordPress, but instead change Gravity…
Category: WordPress
How to move a WordPress database
I often see people asking how to move a WordPress database between servers, and it usually seems like they’re doing it the hard way. I move sites between domains, from PROD to dev, dev to UAT, and so on, and this is how I’ve been doing it for years, 100%…
WordPress – write to .htaccess
If you ever have a need to programmatically write to the .htaccess file, WordPress has a built-in function insert_with_markers to do just that. Calling that function will give you the added benefit of adding “BEGIN” and “END” markers which makes it easier to read. There’s also a sibling function, extract_from_markers,…
ACF Flexible Content image previews, 2.0
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…
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:
How to fix “Error: Another update is currently in progress.”
First, if you aren’t technical AND you don’t have CLI access to your server AND you don’t have WordPress’s CLI tool installed, maybe read this article instead (but don’t install the plugin, just use phpMyAdmin). If you’ve got all of the above, just run:
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…
How to create a command that holds other commands in wp-cli (WordPress CLI)
Almost every major site I work on has at least one custom wp-cli command that I’ve built to manage or automate things. But I always run into the same problem, I don’t want my command to be a root command, I want it to live in a namespace of my…
WPDB Insert automatically changing string format to number
The third parameter to wpdb::insert() is an array of formats that defaults to %s unless they are overridden in wpdb::$field_types. This is last part is very important. When WordPress boots, it statically sets that list to fields that should always be numbers unless someone specifies an explicit format as the…
WP 5.3 – Breaking changes
This is pretty big, and Iām guessing that a good number of people that have WP_DEBUG_LOG turned on (like me, sorry Scott) might see it filling up fast when 5.3 lands, and there might be some fatal errors, too. The discussion is here: https://core.trac.wordpress.org/ticket/47678 The gist is that they are…