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;
}
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.