‘Wptexturize’ (smart quotes) not working in WordPress

by Jakub Marian

Tip: See my list of the Most Common Mistakes in English. It will teach you how to avoid mis­takes with com­mas, pre­pos­i­tions, ir­reg­u­lar verbs, and much more.

I have recently noticed that smart quotes (aka “curly quotes”) stopped working on my blog (they were replaced by the ordinary "straight quotes"). Typography is very important to me, so I tried to fix the problem. It proved harder than I had thought (although the solution turned out to be very simple).

First I thought there would be something wrong with the settings, but there doesn’t even seem to be an option to turn the smart quotes off. So I tried my custom theme using a fresh WordPress installation to make sure the problem was caused by the theme, not by a plugin or a corrupted WordPress installation.

It turned out that smart quotes worked like a charm if I used another theme and stopped working when I used my own. I gradually reduced the content of both my theme files and the theme files of some default WordPress theme to basically a single command:

while ( have_posts() ) : the_post(); 
	echo get_the_content();

in my custom theme and

while ( have_posts() ) : the_post(); 

in the default theme. And this was the culprit. I thought that “echo get_the_content()” was synonymous to “the_content()”, but the difference is that get_the_content() returns the original text before applying any filters (including wptexturize which takes care of smart quotes).

If you have to use get_the_content(), you can apply the filters manually:

while ( have_posts() ) : the_post(); 
	echo apply_filters('the_content', get_the_content());

By the way, I have written several educational ebooks. If you get a copy, you can learn new things and support this website at the same time—why don’t you check them out?