WordPress, Give Me Back My Double Hyphens

Stop Converting Your Double Hyphens

Michael Mann
Note: This is designed for WordPress 2.9 through 3.3.1. The general idea will work for previous versions of WordPress, the exact line number might be different.

There might be a time when you want to post an entry with double hyphens. However, WordPress will take anything with more than a single hyphen and combine them together as a single dash. This can be quite annoying, especially when you cannot see where this setting lives. You look in the dashboard and it's not there. You might not even be the most comfortable with snooping around in the 1000s of files included with WordPress. Have no fear, I have done the snooping and found where this is located and am providing a solution you can implement.

Keep in mind: This setting blog wide. There is no way I know of to change it per post or page.

The replacement of multiple hyphens into takes place in the following file:

wp-includes/formatting.php

Line 56 - $static_characters = array_merge(array('---', ' -- ', '--', ' - ', 'xn--', '...', '"', '\'s', '\'\", ' ™'), $cockney);

Line 57 - $static_replacements = array_merge(array('-', ' - ', '-', ' - ', 'xn--', '...', $opening_quote, ''s', $closing_quote, ' ™'), $cockneyreplace);

The first line are the items you might enter, such as 2 or 3 hyphens in a row. The second line is what the system is setup to replace your entry with. We are interested in the first three items for each of the two lines. Select the first three items and delete them. The result will be:

$static_characters = array_merge(array('-','xn-', '...', '"', '\'s', '\'\", ' ™'), $cockney);
$static_replacements = array_merge(array('-','xn--', '...', $opening_quote, ''s', $closing_quote, ' ™'), $cockneyreplace);

Save the file and re-upload it to your blog. Now when you enter more than one hyphen in a row in a blog post, they will be display correctly.

Published by Michael Mann

With over 12 years of professional experience as a Web designer and over 25 years of general computer experience, I am often the resident tech . I own and operate Michael Mann Desktop Publishing, a desktop p...  View profile

To comment, please sign in to your Yahoo! account, or sign up for a new account.