Support

Account

Home Forums Feature Requests Location = "Nowhere"

Solved

Location = "Nowhere"

  • Don’t know if this would be useful to anyone else, but I find myself in a situation where I’d like to set a field group to not display anywhere. I’ve been thinking about how I could add by creating custom location rules, but I’m not sure by reading the setup of a custom location rule if I could make that work. I can achieve this by creating impossible rules like “Post Type = Post AND Post Type = Page”

  • This Works

    
    add_filter('acf/location/rule_values/post_type', 'acf_location_rules_values_post_type');
    
    function acf_location_rules_values_post_type($choices) {
      $choices['none'] = 'None of the Above';
      return $choices;
    }
    
    add_filter('acf/location/rule_match/post_type', 'acf_location_rules_match_none', 10, 3);
    
    function acf_location_rules_match_none($match, $rule, $options) {
      return -1;
    }
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.