I write My articles in Emacs and they end up having tons of newlines, with double newlines to separate paragraphs. Ideally, I want wordpress to work like markup does, meaning it ignores single line breaks but adds paragraphs when a double newline is met.

Unfortunately, disabling wpautop makes Wordpress ignore both single and double newlines. I want to be able to use the function in a way that ignores <br> tags for single lines but adds <p> tags when two newlines are met.


wpautop can ignore the linkebreaks if you use wpautop( $content, false ); To pass a parameter to wpautop via add_filter, use an anonymous function.

This snippets seems to work for me if I add it to my theme's functions.php:

remove_filter( 'the_content', 'wpautop' );
$br = false;
add_filter( 'the_content', function( $content ) use ( $br ) { 
    return wpautop( $content, $br ); 
}, 10 );

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.