Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

cold_ on "Modify slugs with own algorithm"

$
0
0

Hi there,

I need to get rid of accents of the title being replaced to latin equivalents. For instance from a title 'Hôpital' the post slug will be 'hopital', but I have to get 'hpital'.

I managed to add this to functions.php:

add_filter('post_link','postLinkFilter', 10, 3);
function postLinkFilter($permalink, $post){
	$slug = preg_replace('~([^a-z0-9\- ])~i', '', $post->post_title);
	$slug = strtolower(str_replace(' ', '-', trim($slug)));
	$slug = preg_replace('~\-\-+~', '-', $slug);
	return '/'.$slug;
}

It creates the right slug, replaces links all over the site, but I still can't access posts with the new slug (so it's not changing the slugs in real, just changing links on the site...).

Any idea? Thank you in advance!

[Moderator Note: No bumping. If it's that urgent after waiting just 1 hour, consider hiring someone instead.]


Viewing all articles
Browse latest Browse all 8245

Trending Articles