Skip to content

ACF Custom Filter rules

Drew Baker edited this page Apr 25, 2021 · 1 revision

We have a custom "Page URI contains" ACF filter enabled by default. It's defualts are /contact and /featured/ but it’s easy to add custom ones you might need in functions/acf-functions.php in the acf_location_rules_values_uri_contains() function.

The URI it is testing against is the page/post/custom-post-type URI, with a slash on both ends of the URI.

This is handy for ACF fields that are only needed on the homepage, or on the contact page (or any of it’s child pages).

When you use this feature, be sure to toggle on the Prevent non-developer deletion option on the page edit screen, so that the user can’t change that URI in the future.

Clone this wiki locally