Support

Account

Home Forums Backend Issues (wp-admin) Don't show fields on Taxonomy 'add' form.

Helping

Don't show fields on Taxonomy 'add' form.

  • Haven’t been able to find anyone discussing this, I would like to omit any ACF custom fields from the “Add” taxonomy term field and only show them on the edit term page. It’s just a bit too much to display in the add form.

    Thanks.

  • 
    add_filter('acf/location/rule_types', array($this, 'my_acf_location_rule_types'));
    function my_acf_location_rule_types($choices) {
      if (!isset($choices['Other'])) {
        $choices['Other'] = array();
      }
      if (!isset($choices['Other']['post_level'])) {
        $choices['Other']['taxonomy_form'] = 'Taxonomy Form';
      }
      return $choices;
    }
    add_filter('acf/location/rule_values/taxonomy_form', array($this, 'acf_location_taxonomy_form_values'));
    function acf_location_taxonomy_form_values($choices) {
      if (empty($choices)) {
        $choices = array();
      }
      if (!isset($choices['taxonomy_list'])) {
        $choices['taxonomy_admin'] = 'Taxonomy Admin List';
      }
      if (!isset($choices['taxonomy_list'])) {
        $choices['taxonomy_edit'] = 'Taxonomy Term Admin';
      }
      return $choices;
    }
    add_filter('acf/location/rule_match/taxonomy_form', array($this, 'acf_location_taxonomy_form_match'), 10, 3);
    function acf_location_taxonomy_form_match($match, $rule, $options) {
      $current = 'taxonomy_admin';
      if (isset($_GET['tag_ID'])) {
        $current = 'taxonomy_edit';
      }
      switch ($rule['operator']) {
        case '==':
          $match = ($current == $rule['value']);
          break;
        case '!=':
          $match = ($current != $rule['value']);
          break;
        default:
          // do nothing
          break;
      }
      return $match;
    }
    
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.