How to turn off WordPress smart quotes

Post image for How to turn off WordPress smart quotes

by bledsoe on January 30, 2010

Smart quotes (aka curly quotes) are what most word processor programs insert into your document when you type the quote marks key.  They're pretty to look at, but they cause problems if you use them in a text document that contains code intended to be read by a computer.  That's normally not a problem since text editors don't create smart quotes when you type the quote key, but if you happen to find a cool chunk of code on a blog somewhere and you cut and paste it into a text file, if the blog you're copying the code from uses curly quotes, then you have a problem.

The bad news is, WordPress automatically converts all quote symbols to smart quotes, so if you post code snippets to your blog and they have quote marks in them, anyone who attempts to copy and paste that code into their own text file is going to have problems running the code. The good news is, you can turn this feature off.

There are actually a few different ways to do this, including modifying the functions.php file in your theme folder, or modifying the default-filters.php file in your wp-includes folder. But I like creating a separate php file and making it into a WordPress plugin, as described in this post by Katja Stokley. Create a text file called TurnOffSmartQuotes.php and put this in it:

<?php
/*
Plugin Name: TurnOffSmartQuotes
Plugin URI:
Description: Stops WordPress from converting your quote symbols into smartquotes. The three lines below stop the smartquote conversion in 1) your post content, 2) your comments, and 3) your post excerpts.
Version: 0.1
Author: Katja Stokley
Author URI:
*/
remove_filter('the_content', 'wptexturize');
remove_filter('comment_text', 'wptexturize');
remove_filter('the_excerpt', 'wptexturize');
?>

Then just upload this file to your wp-content/plugins folder, login to your WordPress dashboard, select "Plugins," and activate your new plugin.  You've just turned off smart quotes on your WordPress blog.

Related posts:

  1. Understanding the WordPress API key
  2. A simple tweak for the WordPress YARPP plugin
  3. How to move your WordPress blog to a new host
  4. Merging WordPress blogs
  5. How to align your custom header with your navbar

{ 2 trackbacks }

Disable auto curly quotes in wordpress | FayazMiraz
May 1, 2010 at 10:17 am
Around the WordPress Community: W3 Total Cache, PHP 4 or 5, KSES.php, CRON, and More Links | WordCast - WordPress podcast, Blogging podcast, Blogging news, WordPress plugins, WordPress themes, WordPress news
July 7, 2010 at 7:05 am

{ 5 comments… read them below or add one }

Fayaz March 31, 2010 at 5:00 am

Interesting, I'll add this option to my existing post about disabling smart quotes

Thanks for sharing.
Fayaz´s last blog ..Amazing Adobe Photoshop CS5 with content aware fill My ComLuv Profile

waldner April 29, 2010 at 3:00 pm

Excellent, this is exactly what I was looking for: disable smart quotes but without having to edit some default file.

Thanks!

bledsoe May 1, 2010 at 7:23 am

Thanks Fayaz and waldner, glad you found the info helpful.

Wordpress Tricks June 28, 2010 at 6:59 pm

Hi, i;m have same interesting with you and i found your website from google. You give nice info for wordpress plugin and it's really informatif. Can i copy your post into my blog ?
WordPress Tricks´s last blog ..Post Teaser v401 WP PluginMy ComLuv Profile

bledsoe June 29, 2010 at 9:21 am

Feel free to copy the post if you like, though a link and a shout out is always appreciated.

Previous post:

Next post: