Wordpress - Wordpress automatically adding " "?

I found that non-breaking spaces are being inserted when I use two spaces after a period. The editor seems to interpret the extra space as an attempt on my part to use spaces for text formatting.

If I copy-and-paste my article from the Wordpress editor into a text editor that supports hex display (I use EditPad Pro), I see that text that I thought is a period followed by two spaces is in reality text followed by a single space, followed by the unicode character with the hex code A0, which is the Unicode NO-BREAK SPACE character.

I was able to remove the non-breaking space in existing articles by replacing space followed by the NO_BREAK SPACE character by just a space. In most text editors, you should be able to do that with search & replace by copying the "two spaces" into the Find text box and writing a single space into the Replace text box.

I was able to avoid the issue going forward by only typing a single space after a period.


What's causing this and how do I fix it?

Any content added to or removed from your Post Content is caused by tiny_mce_init, which is applying is's content-filtering rules.

The ways to prevent it are:

  1. Filter tiny_mce_init, to override the default content-filtering rules
  2. Stop switching between Visual and HTML editors. Really; unless you want to use option #1 above, don't switch between editors. WordPress is intended to be used such that content is entered using the Visual or the HTML editor, but not both simultaneously.

Example use for the tiny_mce_before_init filter in Codex. Another example of TinyMCE configuration/customization in Codex here.


All I use is remove_filter( 'the_content', 'wpautop' ); remove_filter( 'the_excerpt', 'wpautop' ); and that stops Wordpress from creating any extra markup. Are you copying and pasting your code from an external editor?

Tags:

Tinymce