Support

Account

Home Forums Backend Issues (wp-admin) Hide Taxonomy Term fields on the main category page

Solved

Hide Taxonomy Term fields on the main category page

  • I’m trying to add group of fields on categories for a custom post type. I can do this by using the Taxonomy Term location option for my field group. However, I don’t want the field group to show up on the main category page, if that makes any sense?

    Can’t figure out how to accomplish this though. Help, please!

    screenshot

  • Use a custom location rule that overrides the ACF location rule for taxonomy https://www.advancedcustomfields.com/resources/custom-location-rules/

    
    // priority 20 runs after ACF built in filter
    add_filter('acf/location/rule_match/taxonomy', 'acf_location_rules_match_taxonomy', 20, 3);
    function acf_location_rules_match_taxonomy($match, $rule, $options) {
      if ($rule['param'] == 'taxonomy' && !isset($_GET['tag_ID'])) {
        // if the rule is for taxonomy but $_GET['tag_ID'] is not set
        // then this is the main taxonomy page and not a term page
        // set match to false
        $match = false;
      }
      return $match;
    }
    

    I’m glad you brought this up, there are many times when I don’t want fields to show on this page and your question made me want to figure out how to do it.

  • so rad. thank you!!!

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Hide Taxonomy Term fields on the main category page’ is closed to new replies.