WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I need to get_the_tag_list but want to remove whitespace within individual tags.

Thus, firefox, internet explorer, opera becomes firefox, internetexplorer, opera

All the filters I found removed whitespace from the HTML, not the content itself.

share|improve this question
up vote 1 down vote accepted
$tags = get_the_tags();
$tag_links = array();

foreach((array)$tags as $tag)
  $tag_links[] = '<a href="'.get_tag_link($tag->term_id).'" rel="tag">'.str_replace(' ', '', $tag->name)).'</a>';

echo implode(', ', $tag_links);
share|improve this answer
Wordpress gives me an error because of the extra ) after $tag->name but once I corrected that, it worked fine. Thanks! – Daze Jul 1 '11 at 21:01

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.