WordPress has a built-in feature that will replace a double dash (noted as “–") with a single, but slighly longer, dash. This is great if you’re a writer or reporter, but it’s damn annoying if you’re trying to write Linux commands, or any other form of code, where you need the -– characters to remain in place. The same applies to quotes (single ' or double “), being replaced with more stylish forward ticks.
So, let’s fix that.
Update: If you’re having troubles replacing the double quotes with WordPress 3.3, have a look here: WordPress 3.3 stop replacing double quotes and single dashes.
****Open up /wp-includes/formatting.php and find the lines around 56 and 57 (this will vary depending on your WordPress version), which start with:
$static_characters = array_merge(array('-–', ' -– ‘, ‘–', ' – ‘, …
$static_replacements = array_merge(array('—', ' — ‘, ‘–', ' – ‘, …
These lines effectively translate your double dashes (–) to the HTML character of a single dash. Remove the third element from every array there, so it looks something like this (please note the line continues, so just remove only the 3rd element from each array).
$static_characters = array_merge(array('-–', ' -– ‘, ' – ‘, …
$static_replacements = array_merge(array('—', ' — ‘, ' – ‘, …
You can now happily write double dashes again!
# ./fix_wordpress.sh –without-silly-dashes –with-something-else
If you want to prevent the single & double quotes as being replaced automatically, open up your functions.php file in your /wp-includes/themes/
# Custom: remove (single & double) quote replacements in posts
remove_filter(‘the_content’, ‘wptexturize’);
This will remove the filter defined in WordPress, so it will no longer replace your single & double quotes.