How to transform the url when there is an apostrophe in the Title?

[ad_1]

Hello friends of Reddit and 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 (each in turn) 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 📷**

[ad_2]
4 Comments
  1. For SEO purposes, the url string should contain the proper spelling, whatever that may be.

  2. You need to use the function add_rewrite_rule() and use a regular expression to match the characters you’re looking to change. This is not exactly what you want but it should help you get started at least.

  3. I haven’t looked it up but I think you might want to try and hook into when a post saves and changing the URL then

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer