How to Disable Smart / Curly Quotes on WordPress 2.5

by Peter Cooper on July 7, 2008

Smart / curly quotes might look nice typographically, but they can be a major pain if you want to copy and paste source code onto your blog (as I do with Ruby Inside and Rails Inside). Luckily there's an easy solution, though it took me a while to discover it.

Basically, go to the functions.php file within your current theme (usually wp-content/themes/[theme name]/functions.php) and add this to the end:

<?php remove_filter('the_content', 'wptexturize'); ?>

Now you're good to go! If you want to be a bit more extreme and remove smart quoting from comments, add this:

<?php remove_filter('comment_text', 'wptexturize'); ?>

{ 11 comments }

1 Brent July 21, 2008 at 10:53 pm

Any thoughts on how to make this work for the post that comes down to the user via RSS?

2 andrew August 27, 2008 at 10:41 pm

Thanks for this bit of code. "str_replace" did not recognize the curly quotes, so my PHP code couldn't replace them, and my RSS was not validating. Placing this line in the function.php file gave me clean RSS that displays in the IE browser perfectly.

3 icie September 27, 2008 at 8:30 am

Thank you so much for this tip. I think there is a more fundamental problem with my WP installation, but WordPress had applied the texturize function on the HTML code of my content, jumbling everything up (you know how important quotation marks are for HTML). That simple line in functions.php saved my sanity.

4 Michael L Perry December 31, 2008 at 7:27 pm

Big thanks.

5 Michael L Perry January 6, 2009 at 6:24 pm

I had a problem after adding this line to functions.php. My site was no longer available at the alias without http://www. I started seeing this error:

PHP Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/wordpress/wp-content/themes/ais2/functions.php:399) in /var/www/html/wordpress/wp-includes/pluggable.php on line 390

Instead of removing the filter in functions.php, I found where it was being added in default-filters.php. I simply deleted those lines.

Thanks for the great tip!

6 Mike Lopez January 14, 2009 at 2:37 am

Brent and Andrew,

To make this work on RSS as well, add the ff:
remove_filter('the_rss_content', 'wptexturize')

7 John P February 12, 2009 at 2:27 pm

Super stuff. Thanks!

8 Chriswaterguy March 4, 2009 at 7:53 pm

Thank you!

9 Klark March 10, 2009 at 6:01 pm

ironically, the comments here have smart quotes turned on. So, you can not simply cut/paste these commands!

10 Peter Cooper March 13, 2009 at 2:41 am

Klark: The first line disables them in posts, not comments. I didn't need it in both.

In any case, I've upgraded WordPress now and am not using this feature anyway ;-)

11 Peter Cooper March 13, 2009 at 3:10 am

Actually, correction.. I am. I just added it back ;-) This time for comments too!

Comments on this entry are closed.