Nov
17
2008

Removing the Smart Quotes from your WordPress Blog

by   |  Posted in Tutorials  |  9 comments

WordPress is great and I pretty much love everything about it. But it does have it’s little idiosyncrasies that can often give you a headache if you don’t really know how to stop it from doing something that you don’t want it to.

When you write a post in the backend of WordPress that includes quotation marks, that same post will appear on the front end with your quotation marks changed into “Smart Quotes”.

That is all fine and dandy, but when it comes to coding, smart quotes ruin everything. I didn’t realize that WordPress did this until I noticed a link back coming into my site and they mentioned that people using one of my tidbits needed to be careful of the smart quotes if they copied and pasted from my site. We can’t have that can we? So here is my simple solution to solving the plain text quotes vs. smart quotes issue.

First we need to open up wp-includes/default-filters.php and look for line 100.

100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// Display filters
//add_filter('the_title', 'wptexturize');
add_filter('the_title', 'convert_chars');
add_filter('the_title', 'trim');
 
//add_filter('the_content', 'wptexturize');
add_filter('the_content', 'convert_smilies');
add_filter('the_content', 'convert_chars');
add_filter('the_content', 'wpautop');
add_filter('the_content', 'prepend_attachment');
 
//add_filter('the_excerpt', 'wptexturize');
add_filter('the_excerpt', 'convert_smilies');
add_filter('the_excerpt', 'convert_chars');
add_filter('the_excerpt', 'wpautop');
add_filter('get_the_excerpt', 'wp_trim_excerpt');
 
//add_filter('comment_text', 'wptexturize');
add_filter('comment_text', 'convert_chars');
add_filter('comment_text', 'make_clickable', 9);
add_filter('comment_text', 'force_balance_tags', 25);
add_filter('comment_text', 'convert_smilies', 20);
add_filter('comment_text', 'wpautop', 30);
 
add_filter('comment_excerpt', 'convert_chars');
 
//add_filter('list_cats', 'wptexturize');
//add_filter('single_post_title', 'wptexturize');

Just comment out a few lines, like I have above, by adding the two slashes (//) before them. Or copy what you see above and paste it over the same line numbers in default-filters.php and all of the quotes on your website will remain as plain text quotes.

About the author:

A freelance web developer living in Montreal who spends most of his time writing for this site and building Premium themes for WordPress. You can find him on Twitter @bavotasan.

Site5 Affiliate Link
If you liked this, please share it.

Tags: , , , , , , , , , , , , , , , ,

Short URL: http://bit.ly/avdOlG

Discussion 9 Comments

  1. c.bavota on November 17, 2008 at 6:40 pm

    For those of you out there who prefer using plugins, I just found a great one that takes care of those nasty smart quotes.

    You can download it at http://www.jasonlitka.com/2007/09/25/wordpress-plugin-disable-wptexturize/

  2. Teknovis on November 26, 2008 at 2:45 am

    Ah… so that is what caused the quote characters to change! It is good to know this tip!

  3. Online Car Insurance >> http://onlinecarinsuranceclaims.com/ on November 23, 2009 at 5:27 pm

    [... - bavotasan.com is other useful authority of tips. Car insurance claims [... -

  4. Linda on January 1, 2010 at 6:31 pm

    Thank you. Still works in WordPress 2.9

  5. app. on April 29, 2010 at 10:07 am

    thats right. great to see it work in 2.9

  6. Katelyn Henderson on May 11, 2010 at 1:38 am

    Some people think that car insurance is a waste of money but it is really very essential that you have one.,.:

  7. Chuck Wyatt on May 13, 2010 at 4:51 pm

    So I betcha this fix works, but it seems like you have to actually modify the core files… ugh. Hate to do that!

  8. Roseanna Single on November 30, 2010 at 10:30 pm

    Insightful writing. Will need a bit of time to think about your stuff.

  9. Kelsi Kirnon on December 1, 2010 at 4:04 am

    Insightful points. Will take a decent amount of time to toy with the info!