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


Removing Sub Category Hyphen Display

  • Fantastic plugin….

    I have been hunting for a solution for 2 days. The Taxonomy field dropdown, displays the sub-category of the taxonomy with hyphen before. This makes the data entry very difficult, because, I have 1000’s of pre-entered choices in taxonomy and manually we are scrolling and choosing.

    If the hyphen is removed, we could type the first few characters of the sub category and choose the required one.

    Here is a screenshot

    This must be a simple to fix for pro’s like you. But, it makes it very hard for me.

    Can you please help me here? to fix this.


  • I’ve done some digging and there aren’t any filters that I can find that allow you do alter the label output.

    You might try looking at and output the value of $field to see if you can alter it at that point, but that’s just a guess.

  • 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;
Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Removing Sub Category Hyphen Display’ is closed to new replies.