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:
- Open the functions.php file in your theme. If that file doesn’t exist, create it.
- Paste the following code:
- 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.
