Last updated on December 15, 2009. Tags: curly quotes, functions.php, smart quotes
I remember the times when I started blogging about websites codes and scripts. Back then, I had several difficulties in using WordPress 2.3 like suddenly changing <br/> tags into paragraph tags <p> and </p> that does not contain anything in between as well as suddenly changing <div> tags into <p> tags.
It ruins the presentation of my blog and I need to be really careful. I did drastic stuff like making a back-up of HTML hand coded copy of my blog posts and not switching to WYSIWYG mode at all times.
Fortunately, WordPress 2.7 no longer do that.
Another difficulty, aside from presentation, is that WordPress tends to change the single and double quotes in the codes into curly ones in my tutorials. I find it rather silly because when I copy and paste codes from my own tutorials, they no longer work. When I examined the source code, the quotes were replaced by something like ‘ and ’, which produce curly quotes like (‘) and (’); they look elegant but they simply don't work in website codes and scripts.
WordPress 2.7 still does that. You type straight quotes such as (') or (") and WordPress replace them with curly quotes (‘) or (”). Fortunately, there is a very simple solution.
All you need to do is to disable the smart quote feature by inserting the code below in the functions.php file of the WordPress theme in use.
remove_filter('the_content', 'wptexturize');
You can insert it anywhere between the very first <?php and the very last ?>. Be sure that they don't interefere with the other PHP codes in functions.php. If you are not sure where to insert, insert it immediately above ?> or immediately below <?php (assuming that there are no other codes aside from <?php and ?> in the first and the last lines respectively).
If your theme has no functions.php, you can create one and insert the code. Be sure that it is enclosed by PHP end tags <?php and ?> as shown below.
<?php remove_filter('the_content', 'wptexturize'); ?>
After doing what was instructed in the previous paragraphs, you can test it by writing a blog entry and type a single quote and a double quote somewhere in the post. Save the post (it doesn't matter whether you publish it right away or save it as draft). Then, preview the post and see if the quotes are straight or curly. If they are straight, check the source code. If you did it correctly, the quotes should be seen as (') and (") even in source codes.
This trick should work for versions 2.3 and 2.7, and any version of WordPress in between. I am not sure of versions of WordPress lower than 2.3, and 2.7 is the latest at the moment I write this post.
Posted by Greten on April 14, 2009 under WordPress tweaks
Please double check your comment before clicking the "Post" button. Once you clicked it, there will be no way for you to edit your comment.
* Required. Your email will never be displayed in public.
Posted by rajesh on 04.20.09 3:08 am
Thanks a lot dear cootleet..i am serching this for a two days…at last i got it from here thanks a lot
Posted by Fayaz on 03.15.10 9:59 am
Thanks, It helped me solve the problem faster.
I’ll add the link of this page to my site soon (my way of saying thanks
)
Posted by Disable auto curly quotes in wordpress | FayazMiraz on 03.17.10 4:54 pm
[...] most cases this will solve your problem. For further information, visit this link: Disabling smart quotes in WordPress No Comment Ping [...]