dash dash

dash dash

The "feature".

Strangely enough, the "code" plugins seem not to work so well on my specific blog template, so, instead of battling further with code-plugin issues (I even tried a few "code"-plugins), I simply decided to tackle the (in)famous "dash" "dash" symbol character (aka - -) WordPress (auto) text formatting "feature" by disabling the "wptexturize" WordPress Filter.

 

tl;dr.

Go to: Dashboard -> Appearance -> Editor -> "functions.php" and paste "add_filter( 'run_wptexturize', '__return_false' );"

 

'The f###..!

On standard/vanilla WordPress, anytime you type two (2) "dash" characters (ie. the minus symbol) on a post (and save), these dashes get automatically converted into "something else" (an em).

  • An em pretty much is not what you originally wrote (so the header!).

In other words, if you originally wanted for two dashes to appear in a post (for whatever reason..), WP would screw you up by automatically replacing them with an em(!).

 

The explanation.

This sneaky text conversion performed behind the scenes by the WordPress engine is a "feature" offered by the wptexturize filter.

A filter is a procedure that "does something if something else happens".

For more info re wptexturize, please refer to here:

source text transformed text symbol name
"---" "—" em-dash
" -- " "—" em-dash
"--" "–" en-dash
" - " "–" en-dash
"..." "…" ellipsis
`` opening quote
"hello “hello opening quote
'hello ‘hello opening quote
'' closing quote
world." world.” closing quote
world.' world.’ closing quote
" (tm)" " ™" trademark symbol
1234" 1234″ double prime symbol
1234' 1234′ prime symbol
'99 ’99 apostrophe before abbreviated year
Webster's Webster’s apostrophe in a word
1234x1234 1234×1234 multiplication symbol

https://codex.wordpress.org/Function_Reference/wptexturize

 

The solution.

My favourite solution was to disable "wptexturize".

Luckily, the WordPress team devised a supported function to simply disable "wptexturize" globally (and without any ill effects so far/on my end).

This solution will simply disable the WordPress text conversion that happens behind the scenes, so all your dashes and quotes will behave consistently between posts.

To disable "wptexturize", proceed as follows:

  1. Login to your Dashboard -> Appearance -> Editor.
  2. Open the Theme Functions "functions.php" page.
    A new page with some code will show up.
  3. Locate the "<?php"-section (usually at the beginning) and paste the below code:

add_filter( 'run_wptexturize', '__return_false' );

Of course, if you'd like to re-enable wptexturize/undo the changes, simply remove the "add_filter (..)" from functions.php.

4.1/5 - (9 votes)