Smart quotes in WP
I didn't like the way WP is adding smart qoutes to my posts. This is especially annoying when you post programming code. So it had to go :-\
I couldn't find an option to disable smart-quoting in the WordPress back-end so I took a look at the code and commented a few lines.
The commented lines were in
/wp-include/functions-formatting.php
in the wptexturize() function
right after the cockney conversions.
/*
$curl = preg_replace("/'s/", '’s', $curl);
$curl = preg_replace("/'(\d\d(?:’|')?s)/", "’$1", $curl);
$curl = preg_replace('/(\s|\A|")\'/', '$1‘', $curl);
$curl = preg_replace('/(\d+)"/', '$1″', $curl);
$curl = preg_replace("/(\d+)'/", '$1′', $curl);
$curl = preg_replace("/(\S)'([^'\s])/", "$1’$2", $curl);
$curl = preg_replace('/(\s|\A)"(?!\s)/', '$1“$2', $curl);
$curl = preg_replace('/"(\s|\S|\Z)/', '”$1', $curl);
$curl = preg_replace("/'([\s.]|\Z)/", '’$1', $curl);
$curl = preg_replace("/ \(tm\)/i", ' ™', $curl);
$curl = str_replace("''", '”', $curl);
*/
In this code snippet, the conversion of (tm) into ™ was also disabled, this is the line before the last one. Feel free to keep it your code, it was just easier to comment out the whole block.
This entry was posted on Monday, March 7th, 2005 and is filed under WordPress. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Get notification for future posts: follow me on Twitter or subscribe to my RSS feed

March 9th, 2005 at 8:00 am
That is useful to know, thanks. The approach I took was to write a plugin to do the job. You can download it from http://www.matt-fletcher.co.uk/index.php/2005/02/04/strip-smart-quotes/
March 9th, 2005 at 11:10 am
Neither solution is OK. Leaving quotes in the xml will produce errors. You need to leave at least one filter, to change the quote marks into ".
February 13th, 2006 at 4:33 pm
This doesn’t work. Smart Quotes need another solution.
May 15th, 2006 at 11:51 am
[...] I don’t see what’s so horrible about Basic ASCII that WordPress had to add “smart quotes” and whatnot. Under your WordPress installation, in wp-includes/functions-formatting.php, there’s a “wptexturize” method that has several preg_replace’s that change your single- and double-quotes into extended set (unicode even?) characters that perhaps look a bit more professional but also aren’t represented in every font out there. I hadn’t noticed as Bitstream Vera handles them just fine, but in the interests of globalization, I went ahead and commented out that bit of code. Thanks to a phpied.com post for this information and a commenter for pointing out WP’s folly. [...]
April 10th, 2007 at 11:13 pm
[...] phpied.com » Blog Archive » Smart quotes in WP [...]
August 16th, 2007 at 4:32 pm
This is the official “right way” to address this stuff, at least in 2.x:
http://wordpress.org/support/topic/125038
You want something like:
remove_filter(‘the_content’, ‘wptexturize’);
in your “functions.php”
October 29th, 2008 at 2:46 pm
[...] One way to change this behavior is to edit some of the WordPress source code (the first issues could be resolved by edits described in WordPress Editor Fix to Stop Stripping or Changing Code and the second, by changes shown in phpied.com » Blog Archive » Smart quotes in WP). [...]
February 12th, 2009 at 6:59 pm
It seems that filter should be removed from the comments as well.
February 14th, 2009 at 10:33 pm
[...] http://www.phpied.com/smart-quotes-in-wp/ [...]
June 3rd, 2009 at 3:01 pm
[...] Smart quotes in WP phpied com Posted by root 1 day 15 hours ago (http://www.phpied.com) Feel free to keep it your code it was just easier to comment out the whole block phpied com is proudly powered by wordpress Discuss | Bury | News | Smart quotes in WP phpied com [...]