How to make sure WordPress displays regular quotes in posts
I can't really say when those fancy quotes started to appear in posts that I made on this WordPress blog, but one day they were there. I did not really put too much thought into it at that time, but when users started to comment on it, I started to take notice. You see, I sometimes post code or commands that users copy and paste into applications. Maybe a path in quotes followed by a startup parameter for Google Chrome, or a command for the Windows command line.
The problem with stylized quotes is that some programs do not see them as quotes. The consequence is dire, as the command or code is not accepted and at best not working, at worst throwing an error message or turning a working product into something that is not working at all.
The screenshot below highlights how those quotes looked like on this site.
I first browsed the style.css file of the theme I was using but could not find any reference to quotes in it. It took a while to figure out what was going on. WordPress is using a Texturize filter by default that modifies certain characters when posts are published.
The WordPress codex has a couple of examples. The two that I encountered are turning two dashes into a single dash, and turning standard quotes into stylized quotes instead. There are more however as you can see from the listing below.
"quoted text" becomes â€œquoted textâ€
'quoted text' becomes â€™quoted textâ€™
--- becomes â€”
-- becomes â€“
... becomes â€¦
(c) becomes Â©
(r) becomes Â®
(tm) becomes â„¢
'' becomes â€
`` becomes â€œ
president's becomes presidentâ€™s
presidents' becomes presidentsâ€™
12' becomes 12â€²
12" becomes 12â€³
2x4 becomes 2Ã—4
The feature is on by default and there is no option to turn it off in the WordPress preferences. You can however turn it off in the following way.
Open the theme folder of the WordPress installation and there the theme that you are currently using. Locate the functions.php file in there and add the following lines of code between <?php ... and ?>
This disables the Texturize filter for comments, the excerpt and the content of the blog.Advertisement