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 }
Any thoughts on how to make this work for the post that comes down to the user via RSS?
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.
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.
Big thanks.
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!
Brent and Andrew,
To make this work on RSS as well, add the ff:
remove_filter('the_rss_content', 'wptexturize')
Super stuff. Thanks!
Thank you!
ironically, the comments here have smart quotes turned on. So, you can not simply cut/paste these commands!
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 ;-)
Actually, correction.. I am. I just added it back ;-) This time for comments too!
Comments on this entry are closed.