Skip to content

Instantly share code, notes, and snippets.

@kellenmace
Created June 2, 2016 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kellenmace/679716ed6be408a107d352e8458177fc to your computer and use it in GitHub Desktop.
Save kellenmace/679716ed6be408a107d352e8458177fc to your computer and use it in GitHub Desktop.
Remove Line Breaks in WordPress
<?php
/**
* Apply new wpautop filter to Press Release content
*/
function km_filter_press_release_content() {
if ( ! is_singular( 'press-releases' ) ) {
return;
}
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