Skip to content

How to prevent double enter on text editor

Stop WordPress from turning every Enter in the text editor into a full paragraph break, by adding one small PHP snippet to your Listivo child theme.

1 minute read

Add the snippet in the child theme, not in Listivo itself — that is what keeps the change through future theme updates.

Then add this PHP code to the functions.php file:

functions.php
remove_filter( 'the_content', 'wpautop' );
remove_filter( 'the_excerpt', 'wpautop' );

function aiooc_crunchify_wpautop_nobr( $content ) {
return wpautop( $content, false );
}

add_filter( ‘the_content’, ‘aiooc_crunchify_wpautop_nobr’ );
add_filter( ‘the_excerpt’, ‘aiooc_crunchify_wpautop_nobr’ );

Result:

The WordPress classic editor on the Text tab, with the quicktag buttons above and two consecutive lines both reading "Text"; the footer shows a word count of 2.

This code removes the p tag when you hit Enter.

Ask the people who build Listivo

We answer by email from support@tangiblewp.com. With Premium Support, we also fix your site when something breaks.

Was this guide helpful?