I assume your setup will recognize URLs formatted this way already?
Add this to your themes functions.php file. It could use some refactoring but it will get you started.
This will update the tag url anywhere that tags are displayed with ‘the_tags’:
function filter_tag_slug_to_id( $content )
{
$dom = new DOMDocument;
$dom->loadHTML( $content );
foreach ( $dom->getElementsByTagName('a') as $node) {
if( $node->hasAttribute( 'href' ) ) {
$url = $node->getAttribute( 'href' );
$tokens = explode( '/', $url );
$term = $tokens[sizeof($tokens)-2];
$tagId = get_term_by( 'name', $term, 'post_tag' )->term_id;
array_pop( $tokens );
array_pop( $tokens );
$newUrl = implode( '/', $tokens ) . "/" . $tagId;
$content = str_replace( $url, $newUrl, $content );
}
}
return $content;
}
add_filter ( 'the_tags', 'filter_tag_slug_to_id' );