Smart quotes in WP

March 7th, 2005. Tagged: WordPress

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

Tell your friends about this post: Facebook, Twitter, Google+

11 Responses

  1. That is useful to know, thanks. The approach I took was to write a plugin to do the job. You can download it from

  2. 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 ".

  3. This doesn’t work. Smart Quotes need another solution.

  4. [...] 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 post for this information and a commenter for pointing out WP’s folly. [...]

  5. [...] » Blog Archive » Smart quotes in WP [...]

  6. This is the official “right way” to address this stuff, at least in 2.x:

    You want something like:
    remove_filter(‘the_content’, ‘wptexturize’);

    in your “functions.php”

  7. [...] 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 » Blog Archive » Smart quotes in WP). [...]

  8. It seems that filter should be removed from the comments as well.

  9. [...] [...]

  10. [...] Smart quotes in WP phpied com Posted by root 1 day 15 hours ago ( 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 [...]

  11. We know a client who had a spa hot tubs costco like this
    some years ago in the 1930′s. Hot Tub covers are not designed to hold a specific number of people etc.

    One of the brothers, Roy Jacuzzi, invented the hot tub to be open.

Leave a Reply