实现这一点的最佳方法是删除默认的sanitize\\u标题过滤器,并将其替换为您的过滤器,这将正确编码这些字符。下面是using accents in permalinks.
示例:
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);
}
}
您可以找到字符及其utf8十六进制
here 并使用所需的重音字符构建一个数组。