WordPress Double Dash Becomes Single Dash
Filed in: WordPress, WordPress Plugins — August 24th, 2005WordPress automatically replace double dash with single dash(em-dash). I show you the solution using a wordpress plugin.
Have you notice that when you write two dash(”–”) in WordPress, it will become single dash(”-” or em-dash) after published? It is due to WordPress wptexturize() function in “wp-includes/functions-formatting.php” file.
The WordPress intention is to make your post more beautiful but the auto formatting feature becomes headache when you need to write those characters without format (example).
Read on for solution to double dash become single dash.
Solution:
You can remarks the $curl lines in wptexturize() function, but not recommended. We should avoid to edit the WordPress core file.
The other better solution is using a WordPress plugin — wpuntexturize. The plugin only works on single and double quotes, NOT dash. So, we need to edit the plugin.
- Open and edit “
wpuntexturize.php” file. - Find:
[php]function wpuntexturize($text) {[/php] - Add these lines immediate under the above line:
[php] $text = str_replace(’—’, ‘—’, $text);
$text = str_replace(’ — ‘, ‘ — ‘, $text);
$text = str_replace(’–’, ‘–’, $text);[/php] - The result should looks something like this:
[php]function wpuntexturize($text) {
$text = str_replace(’—’, ‘—’, $text);
$text = str_replace(’ — ‘, ‘ — ‘, $text);
$text = str_replace(’–’, ‘–’, $text);[/php] - Save the file, upload it to your WP plugin folder. Then, activate the plugin from WP admin. Done.
[tags]Plugin, Plugins[/tags]


