Teacher and coach

How to turn off WordPress smart quotes

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.

16 Responses to “How to turn off WordPress smart quotes”

  1. Fayaz says:

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

  2. waldner says:

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

    Thanks!

  3. bledsoe says:

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

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

  5. bledsoe says:

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

  6. Perfect! Easy and worked like a charm. (and now my readers can cut and paste from my site directly to SQL Server Management Studio).

  7. Bruce Peterson says:

    I suspect I will feel more of an idiot after this is answered than I do now, but here goes anyway. I’m new to WordPress and am being annoyed by the quote handling so I Googled and found this (and a number of other sites all giving similar solutions). The problem is I can’t figure out where the functions.php file (or the wp-includes folder) might reside. The Finder can’t find it locally on my Mac. So I figured that rather than being local to my computer it must be somewhere on a WordPress server somewhere so I went into the Dashboard and started looking around and got no further. Any help would be appreciated. Thanks.

  8. bledsoe says:

    Hi Bruce,

    I’m assuming that your blog is a self-hosted (i.e., wordpress.org) blog and not a wordpress.com blog. (If you have a blog on wordpress.com you might want to check out http://en.forums.wordpress.com/topic/curly-quotes from the wordpress.com forums.)

    If you do have a self-hosted wordpress blog, then yes, the functions.php file and the wp-includes file both live on the server that’s hosting your blog, though you can’t access them directly from your Dashboard. You have to use an FTP client (e.g., Filezilla) or some sort of application from your host’s cpanel screen like FileManager. Both of these allow you to look around your site’s directory structure and also upload files from your local machine to your server.

    Note that there’s also the “Editor” feature in your Dashboard, which does allow you to edit certain of your wordpress files (though it won’t actually show you the directory structure). Inside the Dashboard, on the left sidebar, click on Appearance, then Editor. You’ll be presented with a screen which allows you to edit some of your wordpress files, including functions.php. (Technically, it’s allowing you to edit files within each of your wordpress “themes”.)

    FWIW, I’m not a huge fan of the Dashboard Editor. If I’m going to be editing or uploading files to my server I prefer to use FTP along with my favorite text editor, but I suppose its nice to have options.

    Let me know if this helps.

  9. Bruce Peterson says:

    Actually it is not self-hosted – it’s through WordPress.com. And in looking more closely, the problem only seems to occur in captions of pictures – not in the normal body of the text. When I put a single quote (‘) in the caption of a picture it comes out as this:
    emperors. Following the links you gave me I tried to replace the ‘ with &#39 and ended up with the same character. So perhaps my problem is slightly different than other peoples’. Maybe I just have to rewrite the caption to avoid possessives?

  10. bledsoe says:

    You got me, Bruce, I don’t know much about wordpress.com blogs. I do know they have extensive support thru their forums, though, so that’s probably a good place to look.

    Good luck,

  11. Joe Burnich says:

    Didn’t work for me. Does this not work with the new versions of WordPress?

  12. bledsoe says:

    Hi Joe,

    I have not heard of this fix not working in newer versions of WP. I’m currently using version 3.3.1, and it appears to work as described above.

  13. Just what the doctor ordered! Thanks so much.

  14. Курсы итальянского языка на сайте http://langskype.com/yazyki/italyanskiy. Курсы проводятся в режиме онлайн с русскоязычными преподавателями и носителями языка.

  15. Greg Low says:

    Awesome solution thanks

  16. bledsoe says:

    Thanks Greg, glad it was helpful.

Trackbacks/Pingbacks

  1. Disable auto curly quotes in wordpress | FayazMiraz - [...] Update: If you don't want to modify any existing file, then you can just create a simple plugin, to…
  2. 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 - [...] sharing. Otto shares the code to bring this little link shortner to your own WordPress blog posts.How to turn…
  3. Replacing Smart Quotes with Dumb Quotes in Microsoft Word | Must Be Built - [...] you noticed that WordPress is putting smart quotes around all my quoted text.  Grrrrrr.  Here is how to get…
  4. How to paste HTML code into a Wordpress blog post : WebPublishing.me - [...] to appear anywhere on your blog, you can try modding your functions.php file following these instructions from Lance Bledsoe.…
  5. 워드프레스에서 평범한 따옴표 쓰기 | 노댄스 블로그 - […] 지능형 따옴표 기능을 끌 수 있도록 플러그인을 만들어봤다. 실은 어느 미국 수학 선생님의 블로그에 있는 내용을 아주 조금 고친…
  6. How to turn off WordPress smart quotes - Andy's Blog - […] I realized that the single tick marks were causing the issue. After investigating further, I found this post which…

Leave a Reply

Your email address will not be published. Required fields are marked *

Powered by WordPress | Designed by Elegant Themes