# Adds ability to add break tags on posts
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

add_filter( 'the_content', 'nl2br' );
add_filter( 'the_excerpt', 'nl2br' );

We had the above code in our custom plugin for years and it made the break tag work.

Well it still works. Except multiple line breaks do not work. We can put 50 break tags in a row and the text will just go to the next line. Problem is we need to copy/paste a lot of straight html and spacing is done using break tags.

So why did this stop working when going from 4.4.latest to 4.5.latest? And more importantly what can I do to get tinymce to just read what is there!!?? Also I did try to use the Advanced TinyMCE widget and show paragraph/breaks... That works again but not for multiple. (yes I understand people can have a nonbreaking space in between to show the line - this will involve a lot of work on our part and is truly ghetto)

  • Have you switched themes or tried disabling plugins? That's the first approach. This has a strange solution and states it is due to self-hosted sites and recommends utilizing JetPack - codegena.com/how-to-add-line-breaks-in-wordpress-editor and this was helpful to understand some of the changes. wordpress.org/support/topic/… Commented May 11, 2016 at 21:25
  • @Jarmerson - Of course I have switched themes/plugins. The site is self hosted on a dedicated windows machine. I don't think that matters as I have same performance on other sites.
    – STing
    Commented May 12, 2016 at 16:31
  • To be clear, you have other installations of the latest WP release and they do not have this problem? Commented May 12, 2016 at 16:38
  • 1
    Good to know :) I was curious what might be the cause. Glad you figured it out. Commented Jun 26, 2016 at 8:55
  • 3
    If you figured this out (as its a couple months ago) could you post your solution as an answer and select that answer so this question can be marked as answered. If you haven't yet figured it out edit with an update.
    – thebigtine
    Commented Sep 10, 2016 at 17:17

2 Answers 2


From the comments, problems seems to be related to some plugin misbehaving.

  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review
    – cjbj
    Commented Apr 9, 2017 at 13:34
  • 1
    @cjbj question should be closed as too localised, but there is slim chance for that to happen.... if you have a better answer go for it Commented Apr 9, 2017 at 13:42

When are you calling the code to remove and add the new filters? You can try calling them with a higher priority (if you're calling them from another hook).

Chances are it's due to another plugin or theme doing it's own replacement on the_content ... whether it be calling wpautop itself or removing the nl2br filter.

If it's removing the filter for nl2br you could just call your own function:

add_filter( 'the_content', 'myown_nl2br' );
add_filter( 'the_excerpt', 'myown_nl2br' );

function myown_nl2br($string) { 
    $string = str_replace(array("\r\n", "\r", "\n"), "<br />", $string); 
    return $string; 

Linebreak Reference:

  • windows = \r\n
  • unix = \n
  • osx/mac = \r

You could also just do a call to nl2br() in the function above, but with str_replace gives you an understanding of how it works, and technically nl2br() only inserts a <br/> in front of line break, doesn't actually remove the line break itself.

Tracking down the culprit:

Do a full search on your entire wp-content directory for the_content, and look for any matches where the filter is removed, added, etc. Also search for nl2br and wpautop, that should help track down the culprit.

If for some reason the plugin or theme you find has a callback to a class object's method, the standard remove_filter will not work, here's a response to another question where I posted code to remove a filter when you don't have access to the class object:


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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