Why this remove empty paragraphs from the_content does not works?

It’s not working because:

  • Maybe your filter is running to early as Benoti said in his comments, your filter callback may run before the empty paragraphs are added.

  • Maybe you are dealing with something different than am empty <p></p>, think <br>, &nbsp;

Solution 1:

Disable autop (remove it’s filter).

Solution 2:

add_filter('the_content', 'wpse_244389');
function wpse_244389($content) {
    $pattern = '#<p>(\s|&nbsp;|</?\s?br\s?/?>)*</?p>#';
    $content = preg_replace( $pattern, '', $content );
    return $content;
}

See https://stackoverflow.com/a/14261024/358906