‘Wptexturize’ (smart quotes) not working in WordPress

by Jakub Marian

Tip: Are you a non-native English speaker? I have just finished creating a Web App for people who enjoy learning by reading. Make sure to check it out; there's a lot of free content.

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();
endwhile;

in my custom theme and

while ( have_posts() ) : the_post(); 
	the_content();
endwhile;

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());
endwhile;

By the way, have you already seen my brand new web app for non-native speakers of English? It's based on reading texts and learning by having all meanings, pronunciations, grammar forms etc. easily accessible. It looks like this:

0