Home Forums Backend Issues (wp-admin) Removing Sub Category Hyphen Display Reply To: Removing Sub Category Hyphen Display

  • Although I don’t think that the original issue is still relevant (the select2 search field searches through sub-terms just fine as far as I can tell), here is a method to remove the hyphen from a specific taxonomy field. This is useful in my case where I am creating a select list with child terms only, and it’s cleaner to have them listed without the hyphen:

    add_filter( 'acf/fields/taxonomy/result', 'xyz_remove_hyphen_from_tax_terms', 10, 4);
    function xyz_remove_hyphen_from_tax_terms ($title, $term, $field, $post_id){
      if ($field['key'] == 'field_123'){ // Your custom field key
        $title = str_replace('- ', '', $title);
      return $title;