How to map permalinks with accented letters to sanitized slugs?

The best way to accomplish this is remove the default sanitize_title filter and replace it with yours, which will encode those characters properly. Here is an implementation of using accents in permalinks.

Example:

remove_filter( 'sanitize_title', 'sanitize_title_with_dashes');
add_filter( 'sanitize_title', 'restore_raw_title', 9, 3 );
function sweURLtoCHAR($text)
{
  $url=array(
    "%C3%81","%C3%A1",
    "%C3%8D","%C3%AD"
  );
  $char=array(
     "Á","á",
     "Í","í"
  );

  $str = str_replace($char,$url,$text);
  $str_new = str_replace(" ", "", $str);
  return strtolower($str_new);
}
function restore_raw_title( $title, $raw_title, $context ) {
  if ( $context == 'save' )
   return sweURLtoCHAR($raw_title);
  else {
   $title_new = str_replace(" ", "", $title);
   return strtolower($title_new);
  }
}

You can find the characters and their utf8 hex here and build an array with the accented characters you need.

Leave a Comment