How to turn off WordPress smart quotes

I recently, ran into an issue at work where I needed to find out who had rebooted my server. I recalled writing a post about it here, so I went and snagged the code.

After changing the server name I ran the code and promptly received an error like the one in the graphic above.

After playing around with it for a few minutes, I realized that the single tick marks were causing the issue. After investigating further, I found this post which explains the why and give an example of how to fix it.

You can follow the link if you like, below is what I did.

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.

Update

All, Lance Bledsoe posted, below, about this article not providing a link to his site.

It is important to note that I do not post for recognition, nor do I require it from anyone who copy's from this page, but I would not intentionally prevent anyone from getting the credit they deserve.

In that vein, please visit Lance Bledsoe's site. The information contained there is very useful.

4 thoughts on “How to turn off WordPress smart quotes”

Leave a Reply