Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Remove Line Breaks in WordPress
* Apply new wpautop filter to Press Release content
function km_filter_press_release_content() {
if ( ! is_singular( 'press-releases' ) ) {
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'km_remove_wpautop_line_breaks' );
add_action( 'wp', 'km_filter_press_release_content' );
* Apply wpautop() to content and remove line breaks
* @param string $content the_content().
* @return string the_content() with line breaks removed.
function km_remove_wpautop_line_breaks( $content ) {
return wpautop( $content, false );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.