Removing any and all inline styles from the_content()

If we want to remove all inline styles, then just simply need to add the following code in functions.php.

add_filter('the_content', function( $content ){
    //--Remove all inline styles--
    $content = preg_replace('/ style=("|\')(.*?)("|\')/','',$content);
    return $content;
}, 20);

Leave a Comment