The WordPress content management system has a lousy automatic formatting feature that replaces a double dash for a single, larger dash character.

This tutorial will show you how to solve the double dash problem.

Hardware List:

The following section presents the list of equipment used to create this WordPress tutorial.

Every piece of hardware listed above can be found at Amazon website.

WordPress Playlist:

On this page, we offer quick access to a list of videos related to WordPress.

Don’t forget to subscribe to our youtube channel named FKIT.

WordPress Related Tutorial:

On this page, we offer quick access to a list of tutorials related to WordPress.

Tutorial – WordPress Double Dash

On the Linux console, you need to find and edit the WordPress formatting.php file.

# vi wp-includes/formatting.php

Locate the following lines in the formatting.php file.

$dynamic[ ‘/—/’ ] = $em_dash;
$dynamic[ ‘/(?<=^|’ . $spaces . ‘)–(?=$|’ . $spaces . ‘)/’ ] = $em_dash;
$dynamic[ ‘/(?<!xn)–/’ ] = $en_dash;
$dynamic[ ‘/(?<=^|’ . $spaces . ‘)-(?=$|’ . $spaces . ‘)/’ ]

Comment the following lines to disable the automatic replacement of double dashes for a longer dash.

To comment, just add // to the beginning of the lines.

//$dynamic[ ‘/—/’ ] = $em_dash;
//$dynamic[ ‘/(?<=^|’ . $spaces . ‘)–(?=$|’ . $spaces . ‘)/’ ] = $em_dash;
//$dynamic[ ‘/(?<!xn)–/’ ] = $en_dash;
//$dynamic[ ‘/(?<=^|’ . $spaces . ‘)-(?=$|’ . $spaces . ‘)/’ ]

Now, you can refresh your page and check if our configuration worked.

If you are not using Linux, I think that you can use the Wordpress Editor option available on the Appearance menu of your Dashboard to edit the formatting.php file.