How to get rid of curly quotes in your WordPress blog

Ah, curly quotes. They look nice, but they’re also such a pain if you display code on your blog, or copy/paste it from another blog. Here’s a very simple recipe that I urge you to use if you display code on your blog. Your readers will say thanks you!

This very useful hack is also very simple to implement: Open the functions.php file from your theme (if your theme don't have a functions.php file, create one) and paste the following code:

<?php remove_filter('the_content', 'wptexturize'); ?>

As you can see, we used the remove_filter() function, which allow us to remove a function attached to a particular filter hook.

Filters function are very powerful because they allow you to override some WordPress features without modifying WP core.

27 Responses

Oct 09 2008 09:23

Damn! I was looking for that sinces months! Thank you Mr Kitty^^

Oct 09 2008 11:06

You just saved me lots of headaches! Thanks for the nice tip!

Oct 18 2008 15:47

That’s a hack that I’m very pleased to apply.

Thank you.

Oct 19 2008 07:23

I agree this curly quotes are weird. Specially when someone copies a post edited while TinnyMCE was on or was written in application like MS Word…

Thanks for sharing.

Oct 19 2008 07:57

@J Mehmett: Yeah, curly quotes are a big problem for anyone who display code on his/her blog, and more especially for people who copy it. It has been a source of many errors!

Oct 22 2008 13:12

Nice hack, thank you for share.

Nov 07 2008 17:51

Thank U…

i will try it

Jan 13 2009 16:35

How can same quotes can be removed from comments area? Should I put comment_text in the brackets?

Jan 13 2009 23:53

When i try this, I get the following error.

Parse error: syntax error, unexpected ‘<’ in

The error won’t go away until I FTP over a backup of the functions file - I can’t just delete the offending line from the functions file. Any theories …?

Jan 14 2009 00:00

You know when you ask a question, and then you find the answer straight away … Anyway, dunno if it’s a 2.7 thing, but you don’t seem to need the <php at the front. So you just need:

remove_filter(’the_content’, ‘wptexturize’);
remove_filter(’comment_text’, ‘wptexturize’);

Feb 11 2009 15:39

I still didn’t understand :( how to use it?

Trackbacks:

Leave a Comment

* Name, Email, Comment are Required
Blog And Make Cash