How to transform the url when there is an apostrophe in the Title?
-
Hello friends of WordPress!
Maybe a Stupid question but I prefer to be fixed because being a beginner and learning alone I often make mistakes,)
When I write the title of my page in French: ” Qu’est-ce que le HHC ?”
the url is “transformed” like this for my site:
https://wikihhc.com/faq/quest-ce-que-le-hhc/
but I don’t like the “quest” so I modify the permalink to have:
https://wikihhc.com/faq/qu-est-ce-que-le-hhc/
(So far nothing very complicated lol)
Thus the fact of transforming “quest” into “qu-est” I find that it is more readable like that.
Also in the case of a title beginning with ” c’est quoi? ” for the url I prefer
“c-est-quoi” to “cest-quoi”. .
Does that make sense to you too?
Does this have any influence for Seo?
And especially how to avoid having to manually change my url each time there is an apostrophe in the title of my page/article?
To change the ‘ in – ( and not a merge of words)I tried with these 2 codes in my functions.php file, but it didn’t work:
function custom_permalink_filter($permalink, $post, $leavename) { $permalink = str_replace("'", '-', $permalink); return $permalink; } add_filter('post_link', 'custom_permalink_filter', 10, 3); add_filter('page_link', 'custom_permalink_filter', 10, 3); add_filter('post_type_link', 'custom_permalink_filter', 10, 3);
function custom_sanitize_title($title) { $title = str_replace("'", '-', $title); return $title; } add_filter('sanitize_title', 'custom_sanitize_title', 10, 1); add_filter('sanitize_title_with_dashes', 'custom_sanitize_title', 10, 1);
Thanks in advance for reading this far! and for your help and kindness ??</img>
- The topic ‘How to transform the url when there is an apostrophe in the Title?’ is closed to new replies.