Right, I’m back after the break as I was busy in a stack overflow.Today I’m a going to go over how to replace some text or suffix in WordPress taxonomies. I have noticed in my experience that to solve some small issues take too much time to think that how to do it and this is also one kind of this thing.
Sometimes we are working with some plugin which filter text/taxonomies like category, tags before displaying to the browser. For example,
WPML plugin adds language code suffixes after the taxonomy if such taxonomy entry exists and adds this @lang suffix because WordPress doesn’t allow duplicate taxonomy name. so here I am going to explain how to remove that suffix from taxonomies in WordPress.
Let’s understand by code
1 2 3 4 5 6 7 8 9 10 | foreach ( (array) $terms as $order => $term ) { if (strpos($term->name,'@'.ICL_LANGUAGE_CODE) !== false) $terms[$order]->name = str_replace('@'.ICL_LANGUAGE_CODE, '', $term->name); } return $terms; } |
you can change above code as per your requirement.Ok, that’s it. I hope you enjoyed this tutorial.
Thank you for reading.Feel free to share your thoughts! Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.