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