-
Aug15
-
Wordpress, Stop Changing My Quotes!
-
Alright, so you're copying and pasting something from your blog post into another website and instead of getting Mom's Yummy Cookies you get Mom‘s Yummy Cookies. Of course, the site doesn't allow you to edit anything, so you're screwed.
Okay fine, you caught me, this happened to me. While I wasn't boasting about my mother's delicious cookies, I still endured something very similar while promoting a post. What I'm referring to is Wordpress' default rendering of both single quote and double quote characters.
You'll notice when you create a post in Wordpress; your boring, yet standard, single quote ' gets turned into ‘ and your double quotes " get turned into “. This is what they call "Smart Quotes". What Wordpress is actually doing is replacing the simple, universal, single quote and double quote characters and rendering them as either left single/double quote or right single double quote characters. Let's take a look at it closer.
You type: Mom's Yummy Cookies
Wordpress renders: Mom’s Yummy CookiesOR
You type: Mom told me to tell you "Hello".
Wordpress renders: Mom told me to tell you “Hello”.Let's face it, the Wordpress way is much sexier! Unfortunately, it will cause you problems in situations where you're copying and pasting content from one blog to another, especially in situations where you're pasting code from one blog to another. More over, some applications will not know how to handle these beautiful smart quotes, hence your sexiness is rendered Mom‘s Yummy Cookies. Even worse, if this were a blog post title, word on the street is, Google doesn't like Smart Quotes and may not even index your post correctly. Oh noes! We don't want to upset the Google Gods.
Okay, I get it! Tell me how to fix it!
Alright, so you want to fix this huh? It's really simple. In your Wordpress theme's directory, open up your functions.php file. There are several Wordpress plugins available for doing this, but I personally prefer to go about it without plugins if I can. If you currently do not have a functions.php file in your theme, go ahead and create one.
There a few different choices when deciding to disable the "smart quotes" from your blog, but we'll focus on just the 4 main options when working with the Wordpress texturize filter. The 4 main choices are your post's title, post's content, post's excerpt, and your comment text.
You simply need to put the one's you're looking to disable at the bottom of your functions.php file.
Remove from Post Content
<?php remove_filter('the_content', 'wptexturize'); ?>Remove from Post Title
<?php remove_filter('the_title', 'wptexturize'); ?>Remove from Post Excerpt
<?php remove_filter('the_excerpt', 'wptexturize'); ?>Remove from Post Comments
<?php remove_filter('comment_text', 'wptexturize'); ?>Disable it on certain parts of a post?
Well, there are a couple of options here. You could use a plugin, which would be the easiest, or, you could use the proper HTML character entities in your post, and keep wptexturizer enabled.
Symbol HTML Name HTML Number Description " " " Double Quote ' ' Single Quote ‘ ‘ ‘ Left Single Quote ’ ’ ’ Right Single Quote “ “ “ Left Double Quote ” ” ” Right Double Quote Well, that's it for this quick tip. Let me know if you have any questions! Thanks.
About the author
I love web design and development. It's what I do before bed, and what I can't wait to do when I wake up. So, what do I do when I'm not designing, coding, or dreaming about designing and coding? Well, I'm a music connoisseur, a daddy, a husband, a writer, a joker, and a friend.
Jarod TaylorEnjoy this post?
If you enjoyed this post, please take a second to retweet it, or share it via the various social bookmarking sites below. Don't forget to subscribe to the RSS Feed. If you'd rather customize your subscription options, please visit our subscription page. Thanks again for visiting us!
-
-
Comments
(Add Comment)Leave a Reply
That did it! Cheers, Jarod!
Thank you so much for posting this. Smart quotes have prevented me from submitting sponsored blog entries to certain websites, due to the auto-check thing coming to a screeching halt because the regular quotes are gone (since WP converted them into smart quotes). Your fix worked perfectly.
You’re welcome!
That’s what this site is for, helping people out. Most my posts are created based on my own problems that I eventually solved.
Great information. Two little lines of code solved the problem.
Thank you!
Thanks for sharing.
I initially had content smart quotes off, but later I realized that I had the same problem else where, like title, comments etc. Your post was helpful in that regard.
That did it! Cheers, Jarod!
Thanks for sharing.
I initially had content smart quotes off, but later I realized that I had the same problem else where, like title, comments etc. Your post was helpful in that regard.
Great information. Two little lines of code solved the problem.
Thank you!
Thank you so much for posting this. Smart quotes have prevented me from submitting sponsored blog entries to certain websites, due to the auto-check thing coming to a screeching halt because the regular quotes are gone (since WP converted them into smart quotes). Your fix worked perfectly.
nice post,thanks for share.
This is great information. Unfortunately it may not work on a theme that uses Cufon font replacement such as Woo’s Bueno theme.
I wish I’d been aware of this before–as texturize was causing my RSS feeds to come out strange-looking.
So, thanks for helping me fix that.
I have another question about single quotes though, if anyone knows more than I do:
On my site (http://www.runhundred.com) the search works fine–for the most part.
But, if anyone searches for a post with a single quote/apostrophe (like Guess Who’s Coming To Dinner) the search not only fails to find the post, but also gets this error:
Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource
Any ideas on how to fix this?