How To Fix WordPress Quotation Marks

I was going through a previous post to check how to increase the memory limit on a WordPress install.

When I copied the code, I realized there was a big problem: WordPress was automatically changing "straight quotes" into "smart quotes".

How to fix WordPress quotation marks: Go to functions.php and add this code: remove_filter('the_content', 'wptexturize'); making sure it's in a child theme. That's all you need to do.

See our tutorial on how to create a WordPress child theme if you don't already have one.

You're changing this:

Into this:

To change WordPress "Smart Quotes" to straight quotes in the titles, add this code to functions.php: remove_filter('the_title', 'wptexturize'); Be sure to save it in a child theme.

You don't notice the smart quotes when you're writing, because WordPress only switches it on display.

The straight quotes are saved to the database, regardless of whether you remove the wptexturize filter or not.

There's a plugin that claims to fix these smart quotes before they hit the database, but that's not how WordPress does it any more. No need for it, just add one line to your functions.php.

Why use straight quotes rather than smart quotes?

Ordinarily, it doesn't really matter which style you use. It will usually just come down to personal preference.

If you're posting code, like I am on this site, having smart quotes will cause issues with anyone who copies and pastes your code.

wptexturize doesn't just affect quotes. It also changes dashes and ellipses, among other things. See the WordPress reference for everything it changes.

Mike Haydon

Thanks for checking out my WordPress and coding tutorials. If you've found these tutorials useful, why not consider supporting my work?

Buy me a coffee

Leave a Comment