Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Mr2P/4012654 to your computer and use it in GitHub Desktop.
Save Mr2P/4012654 to your computer and use it in GitHub Desktop.
Wordpress: Append span tag to each "tag item" returned from get_the_tag_list()
$tags_list = get_the_tag_list( 'Tags: ', __( ', ', 'text_domain' ) );
preg_replace_callback('/<a\b[^>]*>(.*?)<\/a>/',create_function('$matches','return "$matches[1]";'),$tags_list);
preg_replace('/(<a\b[^>]*>)(.*?)(<\/a>)/', '$1<span class="tag-label">$2</span>$3', $tags_list);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment