↓ Archives ↓

Disable auto curly quotes in wordpress

After my last post about Changing WordPress URL, I found that a simple COPY/PASTE of the code I provided don't actually work, since WordPress converts straight single/double quotes to curly quotes. Although it looks good, but it doesn't work when used as CODE. See How to Fix this problem:
This is strictly a WordPress theme setting. WordPress saves in database exactly what you see in your WYSIWYG editor. Some themes already handle this (since they are CODE friendly), but other wordpress themes are more Human Eye friendly, so they convert straight quotes to curly quotes.

There are two main ways to stop this automatic behavior:

  1. Edit the functions.php file of your current WordPress Theme.
  2. Use a WordPress Plugin to do the Job for you.

Follow any one option that feels most suitable to you.

Option-1: Edit the functions.php file of your current WordPress Theme:

// Add the following line in the functions.php file of your current WordPress Theme:
remove_filter('the_content', 'wptexturize');

remove_filter('the_excerpt', 'wptexturize');

remove_filter('comment_text', 'wptexturize');

If you can't find the functions.php file, look inside the following directory structure:

Your_WordPress_Installation_Folder/wp-content/themes/Your_Current_Theme_Folder/functions.php

If the file doesn't already exist there, then create the file (name it: functions.php) and use the CODE below:

<?PHP

remove_filter('the_content', 'wptexturize');

remove_filter('the_excerpt', 'wptexturize');

remove_filter('comment_text', 'wptexturize');

Remember, there should be no space or new-line (or anything else) before the PHP start tag (<?PHP)

Option-2: Use a WordPress Plugin to do the Job for you:

If you don't want to modify any existing theme file (or perhaps you want it to apply to all themes, so that when you decide to use a new theme, you don't have to do it again), then you can just create a simple WordPress Plugin, to do the trick for you. Do the following:

Create a new file called DisableSmartQuotesPlugin.php and use the following CODE:

<?PHP
/*
Plugin Name: DisableSmartQuotesPlugin
Plugin URI: http://www.fayazmiraz.com/disable-auto-curly-quotes-in-wordpress/
Description:  WordPress Plugin to Disable auto curly quote conversion in post content, comment content and post excerpt
Version: 1.0
Author:  Use Your Name
Author URI:
*/
remove_filter('the_content', 'wptexturize');

remove_filter('the_excerpt', 'wptexturize');

remove_filter('comment_text', 'wptexturize');

Then upload this file to the following directory structure:

Your_WordPress_Installation_Folder/wp-content/plugins/

Then, login to your WordPress Admin Panel (Your_WordPress_URL/wp-admin/), go to Plugins menu and activate this new plugin named DisableSmartQuotesPlugin or whatever the name you choose to give.

Now you're all set and your WordPress will no linger automatically convert single/double quotes to curly quotes.

Note: The provided CODE in both the above options disable auto-smart quote conversion to three sections of your post:

  1. Post Content
  2. Post Excerpt
  3. Comment Content

It's most likely that you'll have CODE only in either one of the above sections. However, If you want to disable auto-quote conversion in other sections of your post (like Post Title, post tag etc.), then use the filters for those sections too.

// this is the CODE for title

remove_filter('the_title', 'wptexturize');

WordPress filter reference is given below.

References:

4 Comments | Pings

  • Mar 26th 201008:03
    by Raquib

    Reply

    Thanks for sharing.

    I previously worked with wp-themes which had this option enabled by default. So I didn't see the problem until recently.

    Thanks to u, i've found the soln quickly.

  • Feb 24th 201121:02
    by annunci economici

    Reply

    Thanks for all the information you give on the blog.
    thank you very much by

    laura

  • Oct 7th 201104:10
    by Greg

    Reply

    You rock! Perfect solution.



  • This Post is Recommended by:

    » EDBloggen »Turn WordPress conversion of quotes and apostrophes

    Leave a Reply