Home › Forums › ACF PRO › Detect if a field is being loaded for editing or for being displayed › Reply To: Detect if a field is being loaded for editing or for being displayed
I would most likely conditionally add the filter.
In functions.php or wherever you are adding the filter
if (!is_admin()) {
add_filter('acf/load_value/name=field-name', 'your-function-name');
}
This would mean that the filter would not be applied in the admin or during any ajax requests.
If you wanted to make it even more specific you could add the filter only just before your got the field. This would ensure that it is only applied when you want it to be applied.
add_filter('acf/load_value/name=field-name', 'your-function-name');
$value = get_field('field_name');
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.