WordPress Remove Auto Line Breaks From Content and Excerpt Function to remove the filters


Example

/**
 * Remove the automatic line breaks from content and excerpts.
 *
 * @since 1.0.0
 */
function remove_content_auto_line_breaks() {
    // Remove the auto-paragraph and auto-line-break from the content
    remove_filter( 'the_content', 'wpautop' );

    // Remove the auto-paragraph and auto-line-break from the excerpt
    remove_filter( 'the_excerpt', 'wpautop' );
}

// Execute the function
remove_content_auto_line_breaks();