filter for *custom taxonomies* with comma
-
I’ve finally figured out how to allow comma for tags but haven’t figured out for the custom taxonomies. (source: Filter Tags with Commas)
// filter for tags with comma // replace '--' with ', ' in the output - allow tags with comma this way if(!is_admin()){ // make sure the filters are only called in the frontend function comma_tag_filter($tag_arr){ $tag_arr_new = $tag_arr; if($tag_arr->taxonomy == 'post_tag' && strpos($tag_arr->name, '--')){ $tag_arr_new->name = str_replace('--',', ',$tag_arr->name); } return $tag_arr_new; } add_filter('get_post_tag', comma_tag_filter); function comma_tags_filter($tags_arr){ $tags_arr_new = array(); foreach($tags_arr as $tag_arr){ $tags_arr_new[] = comma_tag_filter($tag_arr); } return $tags_arr_new; } add_filter('get_terms', comma_tags_filter); add_filter('get_the_terms', comma_tags_filter); }
What I’m struggle to do is to have it work for custom taxonomies. I have Authors (that contains LName, FName) and Artists (Which also contains LName, FName).
Anyone know a way to modify the code I included above that would work with the custom taxonomies? I’ve successfully included the custom taxonomies to the single page by using this code:
echo "<div class='tags'><span>"; echo get_the_term_list( $post->ID, "artists", "Artist:??</span>", ", ","</div>" );
So, I was wondering if I should use the same ‘get_the_term_list’ part somewhere in the first code block above?
Many thanks to anyone who could figure it out. If I ever figured it out, I’ll post the solution on here.
- The topic ‘filter for *custom taxonomies* with comma’ is closed to new replies.