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.
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.