Hyphen is turned into HTML hexadecimal code in “view source” mode

[ad_1]

Hello!

This is intentional behavior and there’s nothing you need to do. Search engines and all popular social platforms can decode special HTML characters from titles and descriptions; after all, HTML elements may contain HTML entities.

Here’s why we do this: TSF parses titles and descriptions through WordPress’s texturization (wptexturize()), which converts hyphens (charcode 45) to en-dashes (charcode 8211). Funnily, its documentation page fails to show a hyphen correctly but shows an en-dash instead.

In any case, because the hyphen is often used as a title separator, we want to maintain the unaltered hyphen. So, to prevent wptexturize() from converting the hyphen to an en-dash, we convert the hyphen to an HTML formatted hyphen: -.

Still, some users wish to show an em-dash (using two hyphens: -- = ), or endash as intended. So, we determine when we insert the - using advanced regex.

I hope this makes sense. Cheers!

  • This reply was modified 3 minutes ago by Sybre Waaijer. Reason: formatting

 

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