If you’ve ever tried to add a non-breaking space – – in the text editor in WordPress, you know that it disappears once you return to the visual editor and save the page. Next time, try putting this bit of code in your functions.php file to stop WordPress from removing your non-breaking spaces (and ampersands and greater than/less than signs):
function dmcg_allow_nbsp_in_tinymce( $init ) {
$init['entities'] = '160,nbsp,38,amp,60,lt,62,gt';
$init['entity_encoding'] = 'named';
return $init;
}
add_filter( 'tiny_mce_before_init', 'dmcg_allow_nbsp_in_tinymce' );
Yan says
Oh my god, thanks a zillion, Debbie, you just made my day!
I’m just sooo mad every time I have to format text blocks on my websites 😉
Cheers, Yan.
Debbie says
Always makes me smile when my long searches result in helping someone else.