I’m ditching curly quotes. If you’ve come across this post via a web search, you probably already know that WordPress replaces apostrophes and double quotes with prettier “curly” versions, like this:
"I'm in double quotes." → “I’m in curly quotes!”
It does this with the best of intentions, I’m sure, and I think the curly quotes look very nice, but I don’t want them anymore. And if you clicked on this page in your search results, it’s likely you want to remove them also, along with other “character entity reference” conversions, e.g. double dash (--) to em dash (—). (Or maybe you were searching for how to suppress “smart” quotes?)
It’s easy to change this behavior, and it doesn’t require a plugin. You just need to add a few lines to one of your theme files. Before we get into that, let’s ask:
Why not pretty formatting?
-
To prevent WordPress from mangling code samples. This is the most common complaint I’ve seen. You’ll still have other things to watch for, though, and you might want to look at a plugin to help with code formatting.
I’m going to continue using my Java program, the WordPress Code Helper, to handle the other display problems and to be prepared for the day I decide to switch back to the curly side.
-
To prevent the appearance of illiteracy. This is kind of a limited case, but I’ve been bothered for a long time by the way FeedBurner strips out character entities in the plain text version of RSS feed items that are sent out to email subscribers. I hope this takes care of that. (Of course, I’m still going to lose italics and bold in the plain text.)
-
For simplicity’s sake. I’d like to stay as close to bare metal ASCII text as possible. When I copy and paste from a WordPress blog into a plain text file, the fancy characters clash with the basic .txt feng shui. (Still, alas! We’re losing italics in that text file.)
This is mainly why I’m doing this now. Not so much because of the copy-and-pasting — that’s just a symptom of curly quotes dissonance — but really for the sake of keeping things simple.
Silly me. We’ve already established that you don’t want them. I’m sure you have your own reasons. (Feel free to comment on them below.) Was it really necessary for me to elaborate? No, it wasn’t. But thank you for staying with me so far.
Why not a plugin?
There are plenty of plugins out there for this. Just try searching for [wordpress no curly quotes] and you’ll find a whole bunch. (Hey! There’s my character entity post near the top of the results!)
For example, here’s the “No Curly Quotes” plugin from which I learned the four calls to the remove_filter function to turn off conversions for post contents, title, comments, and excerpts. (Some pages only mention the call for post contents, so this was good to find.)
But I have way too many plugins already. It’s awesome to have all these great plugins out there for WordPress, but they create maintenance headaches. So I avoid them if I can.
For this job, you just need four lines in your:
functions.php file
<?php
remove_filter('the_title', 'wptexturize');
remove_filter('the_content', 'wptexturize');
remove_filter('the_excerpt', 'wptexturize');
remove_filter('comment_text', 'wptexturize');
?>
functions.php is a theme file which you might find (strangely enough) in your themes directory. You might find it there. I didn’t have one so I had to create it, and what you see above is currently my entire file.
Once I had the file in place, it just started working. No more curly quotes!
I also cleaned up several other theme files and plugins where I had hardcoded character entity references. And I have some old posts where I added references, but I’m going to try not obsessing over those. (WordPress would sometimes put the wrong facing quote in, prompting me to override with the correct one.)
All right. Enough said. I really only intended to post a short FYI note for the Internet.

One Comment
Thanks! This is exactly what I was looking for.
1 January 2010 at 2:50 pm