Adding Tags with commas in them?
I have a taxonomy that I imported into WordPress. When tagging my post I ran into the issue of terms being broken into two when there was a comma in them. I can see why this happens since the comma is what WordPress uses to seperate multiple tags in an input field. The problem comes up when you have a taxonomy filled with people’s names in the format “Lastname, First name” or in large dollar amount like “$10,000 – $19,000”.
This will let me add the tag successfully, as one tag and not two. The problem is when I save the post, some PHP function breaks up the tags at the comma and my post now has two tags instead of the expected one.
I would be happy to write a plugin to modify this behavior if only I knew of the right filter or action to hook on to for the parsing of the tags on the backend. Does anyone know?
Or does anyone have an idea on how to add tags that have commas in them?
With the new custom taxonomy features in WordPress 3.0 I fear this will become more and more of a problem and I don’t think it would be that hard to fix it if I just knew the right place to look.
Did you arrive to a solution for this? I’m in the same trouble, I have a taxonomy of Artists and want to put them “Lastname, First name”, but then I have two items instead of one.
Agreed – I am setting up WP 3.0 with many custom taxonomies and need to follow the Library of Congress Name Authority File that requires Lastname, Firstname format. I am stuck entering tags for persons as Lastname – Firstname, which doesn’t quite cut it. I seem to remember that somewhere – in a Typepad blog or Flickr – that I could enclose tags in quotations that are separated by commas – i.e., “Lastname, Firstname” and have them stay as one tag. How would you go about writing a plugin for something like this?
I have set up a work-around for this issue – not a great solution, but an improvement over what I was doing previously:
I am still entering tags for persons in the metabox as Lastname – Firstname but I have added some code to my single.php script to do a str_replace() for the dash replacing it with a comma. This way my tag displays Lastname, Firstname. Search results seem to work well (I am using Search Everything plugin). My code looks something like this:
<?php $persons_list = get_the_term_list( $post->ID, 'persons', 'Persons: ', ', ', '' ); $dash_to_comma = str_replace(' - ', ', ', $persons_list); echo $dash_to_comma; ?>
Let me know if anyone can think of a better way to do this – especially if it involves writing a plugin to change how the tags are entered in the metabox to begin with. Thanks
- The topic ‘Adding Tags with commas in them?’ is closed to new replies.