TipsWordpress Display standard quotes in a WordPress post

Single and double quotes typed in a post are displayed by WordPress as directionnal quotes: ‘blabla’ or “blabla” (I.e.: left/right single/double quotes). This becomes an issue when publishing “shell scripts” samples to be copy/pasted. The solution is to type “encoded quotes”. Ex.: & #39; for ' or & #34; for " (without the blanks between & and #).

Click to Read More

This is due to the WordPress converting Straight Quotes to Pretty Quotes… a feature also named Smart Quotes and due to a filter running in WordPress: the “wptexturize”.

Here after, an example I used to post to illustrate how to send custom notifications from a script running on a Synology. The code was directly copy/pasted here from a shell script opened within Notepad++ (where the quotes appeared as &#39 and &#34).

/usr/syno/bin/synonotify Tag_Name ‘{“[%VAR1%]”: “value1”, “[%VAR2%]”: “value2”}’

As you can see above, the single and double quotes are displayed by WordPress as symbols: ‘…’ and “…”.

The problem is that readers who copied/pasted as-is this sample in their script got execution errors. Indeed, a ‘ and a &#39 are not interpreted the same way within a shell.

To solve this issue, I did replace all ‘ and ” respectively by & #39 and & #34 (without the blanks between & and #). I don’t use the menu Insert > Special Character as

Another option would be to disable the “pretty-fication” feature… This can be done by opening up your theme’s functions.php file and pasting the following code at the bottom right before the closing ?> PHP tag:

remove_filter('the_content', 'wptexturize');

Notice that Quotes in preformatted text (as here just above) are not replaced by Smart Quotes. But one one side, this can’t be used on Quotes typed inline, and on the other side, I don’t use preformatted text for my code samples…

Yet another option would be to use a plugin like the Smart Quote Fixer to remove the Smart Quotes.

But I prefer to use type the num codes as I don’t want to disable Smart Quotes on the complete post…