Using Normal Quotes Instead of Curly Quotes


The problem. If you’re a developer who often publishes code snippets on your website, you have probably encountered the following problem: a user tells you that the code you posted doesn’t work. Why? Simply because, by default, WordPress turns normal quotes into so-called “smart quotes,” which breaks code snippets.

The solution. To get rid of theses curly quotes, proceed as follows:

  1. Open the functions.php file in your theme. If that file doesn’t exist, create it.
  2. Paste the following code:

    1 <?php remove_filter('the_content', 'wptexturize'); ?>
  3. Save the file, and say goodbye to broken code snippets!

Code explanation. The wptexturize() function automatically turns normal quotes into smart quotes. By using the remove_filter() function, we tell WordPress that we don’t want this function to be applied to a post’s content.

Source:

You may Also Like

  1. Display AdSense Ads to Search Engines Visitors Only
  2. Deny Comment Posting to No Referrer Requests
  3. Using CSS Sliding Doors in WordPress Navigaton
  4. Avoid Duplicate Posts in Multiple Loops
  5. Automatically Get Images on Post Content

Tags:

Responses are currently closed, but you can trackback from your own site.