Disable wpautop, keep line breaks

How can I disable automatic paragraph tags, but retain line breaks?

I have used this to remove wpautop:

Read More
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

But there are no more line breaks in the text.

Related posts

1 comment

  1. Here’s the full solution.

    First disable wpautop in your functions.php

    remove_filter( 'the_content', 'wpautop' );
    remove_filter( 'the_excerpt', 'wpautop' );
    

    Then parse your content/excerpt with nl2br (a standard PHP function).

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

Comments are closed.