Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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

1 Answer 1

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

 
discard

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.