How to make sure WordPress displays regular quotes in posts

Martin Brinkmann
Mar 16, 2013
Updated • Mar 16, 2013
Development
|
1

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.

stylized quotes
WordPress using Texturize filter

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 ?>

remove_filter('comment_text', 'wptexturize');
remove_filter('the_excerpt', 'wptexturize');
remove_filter('the_content', 'wptexturize');

remove filter wptexturize

This disables the Texturize filter for comments, the excerpt and the content of the blog.

Advertisement

Previous Post: «
Next Post: «

Comments

  1. getintopcpw said on November 28, 2017 at 6:15 am
    Reply

    Pale moon 64-bit is an Open Source, Goanna-based web program accessible for Microsoft Windows What’s more Linus Pauling (with other working frameworks done development), keeping tabs once effectiveness Furthermore simplicity from claiming use.

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

We love comments and welcome thoughtful and civilized discussion. Rudeness and personal attacks will not be tolerated. Please stay on-topic.
Please note that your comment may not appear immediately after you post it.