WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I often add   between connecting words so they break down together to a new line in important text. Switching to visual tab then back to text tab removes these. What can I do to keep them and avoid TinyMCE removing them?

I found this but not sure how to apply it to WordPress: http://www.abeautifulsite.net/blog/2009/12/tinymce-removes-non-breaking-spaces/

My ugly solutions would be using a different custom string between words__like__this then later replacing them to   in PHP, before display. Or just typing it on the visual tab, which translates to   but then converting them with PHP.

share|improve this question

This seems to do it:

function allow_nbsp_in_tinymce( $mceInit ) {
    $mceInit['entities'] = '160,nbsp,38,amp,60,lt,62,gt';   
    $mceInit['entity_encoding'] = 'named';
    return $mceInit;
add_filter( 'tiny_mce_before_init', 'allow_nbsp_in_tinymce' );

Any improvement suggestions?

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.