Support

Account

Home Forums Front-end Issues Front-end acf_form: field validation returning a WP error page Reply To: Front-end acf_form: field validation returning a WP error page

  • In my functions.php file, I added the following:

    if (!is_admin()) {
    	add_filter('clean_url', function($url) {
    		if (strpos($url, '.js') === false || strpos($url, 'jquery.min.js') != false || strpos($url, 'acf') != false) {
    			return $url;
    		}
    		
    		return "$url' defer='defer";
    		
    	}, 11, 1);
    }

    The clean_url filter modifies the URL of any script being enqueued – this is where I was adding my own defer property to my scripts. However, as this was causing an issue with my ACF forms, I added an exception so that it didn’t add a defer for any ACF scripts.

    If you’ve got something else that’s handling script deferment, you’ll need to check to see if it has hooks that allow you to add exceptions.