Disabling smart quotes in WordPress

Last updated on February 11, 2013. Tags: , ,

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 and later versions no longer do those.

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. This still happens up to WordPress 3.5, the latest version at the time this post was updated.

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 &#8216; and &#8217;, which produce curly quotes like (‘) and (’); they look elegant but they simply don't work in website codes and scripts.

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');

If you are not sure where or how to insert this code in functions.php. click here.

After this, 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 method should work for versions 2.3, 2.7, and 3.5, and any version of WordPress in between them; it is also likely to work in versions lower but close to 2.3 and higher but near 3.5

Posted by Greten on April 14, 2009 under WordPress

Read Comments
Fayaz says:

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 :) )

[...] most cases this will solve your problem. For further information, visit this link: Disabling smart quotes in WordPress No Comment Ping [...]

Share your thoughts

Comment Rules and Reminders

  • When you comment, please say something that indicates that you indeed read my post. If your comment is a general statement that can fit to any blog post about any topic, it will be regarded as spam.
  • What you write in the name field should be your actual name, part of your actual name, or your nickname, and should only be four words at maximum
  • No links in the body of the comment itself. If referring to an external source is essential, please type the URL with space between each character e.g., codegrad.hub.ph becomes c o d e g r a d . h u b . p h. Do not hard code the URL as HTML link.
  • 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.
  • Fields marked with asterisks (*) are required. Your email will never be displayed in public.
Codegrad

HTML, CSS, Javascript, search engine optimization, WordPress customization and other web development tutorials by Greten Estella