Regarding the why part, I think I’ve traced this to the following line:
$title = preg_replace('|-+|', '-', $title);
within the sanitize_title_with_dashes()
function.
It’s added to the santize_title()
via the filter:
add_filter( 'sanitize_title', 'sanitize_title_with_dashes', 10, 3 );
but I wouldn’t recommend removing it totally.
Update:
Here’s a quick and dirty way around this:
add_filter( 'sanitize_title', function( $title )
{
return str_replace( '--', 'twotempdashes', $title );
},9 );
add_filter( 'sanitize_title', function( $title )
{
return str_replace( 'twotempdashes', '--', $title );
},11 );
where we replace two dashes into some temporary string, before the sanitize_title_with_dashes
is activated and then replace the string again to two dashes afterwards. We could adjust this to the more general case, but you get the idea 😉