When I write my site’s title, description, posts, pages, or a taxonomy description, small dashes -
are turned into longer, uglier ones –
.
Is there some way to stop this from happening? Can I put some sort of function in my functions.php? Any ideas?
-
is a hyphen or minus, not a dash. Converting it to an en dash is actually the correct thing to do from a typographical standpoint.http://en.wikipedia.org/wiki/Hyphen-minus
Typography is one of those deep-read kind of ideas, but the bottom line is that you think the hyphen minus is the correct character to use because of limitations in early typewriters. The correct character to use in most all the instances where you type the minus sign, from a typesetting and printing (and now, web) point of view is actually the en dash.
But if you really want to use incorrect typography, then bungeshea’s approach above will work, or you can remove the wptexturize filter from the_content. The wptexturize function corrects this common typographical mistake, as well as fixing quotes, apostrophes, primes and double primes, dashes, whole bunch of other stuff. Basically it transforms what you type into the correct typography for it.
The transformation happens in the
wptexturize()
function. It turns a regular dash (-
) into an en dash (–
). The function translates the en dash using the_x()
function, which in turn uses thegettext_with_context
filter. We can hook into this filter to return a regular dash instead of an en dash:However, as explained in Otto’s answer, it’s typographically correct to use an en dash instead of a hyphen/minus sign. But it is your site, so whatever works for you and your users.