0

I noticed that TinyMCE adds a non-breaking space after a horizontal rule element, this isn't required and adds additional space to my layout if there isn't any content after the <hr/>

I've tried configuring TinyMCE via functions.php but nothing prevents the nbsp being added:

add_filter('tiny_mce_before_init', mce_mod( $init ) {
    $init["convert_newlines_to_brs"] = true;
    return $init;
})
0

Turns out I wasn't far from the answer:

function mce_mod( $init ) {
  $init['apply_source_formatting'] = false;
  return $init;
}
add_filter('tiny_mce_before_init', 'mce_mod', 99);

add this to functions.php and it will stop the nbsp's.

From the TinyMCE docs

if you want to fully tame tinyMCE I recommend you check out this gist

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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