i need to convert this strings into the post url:
(numbers with the point and € symbol) ex: 9.000€ -> 9000-euro
I found this function but is not working:
add_filter( 'sanitize_title', 'sanitize_title_extra' );
function sanitize_title_extra( $title ) {
$friendlyURL = htmlentities($title, ENT_COMPAT, "UTF-8", false);
$friendlyURL = preg_replace('/&([a-z]{1,2}) (?:acute|lig|grave|ring|tilde|uml|cedil|caron);/i','1',$friendlyURL);
$friendlyURL = html_entity_decode($friendlyURL,ENT_COMPAT, "UTF-8");
$friendlyURL = preg_replace('/[^a-z0-9-]+/i', '-', $friendlyURL);
$friendlyURL = preg_replace('/-+/', '-', $friendlyURL);
$friendlyURL = str_replace( '€', 'euro', $friendlyURL );
$friendlyURL = str_replace( '€', 'euro', $friendlyURL );
$friendlyURL = str_replace( '€', 'euro', $friendlyURL );
$friendlyURL = trim($friendlyURL, '-');
$friendlyURL = strtolower($friendlyURL);
return $friendlyURL;
}
Thanks! 😉
If you a look at the source you’ll see it’s because the
sanitize_title
filter fires afterremove_accents()
is called bysanitize_title()
.It does however, pass the raw title as the second argument so you can perform any substitutions on the raw title, apply
remove_accents()
and return it: