Created
June 2, 2016 18:41
-
-
Save kellenmace/679716ed6be408a107d352e8458177fc to your computer and use it in GitHub Desktop.
Remove Line Breaks in WordPress
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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