Wordpress - remove empty paragraphs from the_content?

I had the same problem you have. I just did a... let's say... not very beautiful solution, but it works and so far it's the only solution I have. I added a little JavaScript line. It needs jQuery, but I'm sure you can figure it out without.

This is my tiny JS:

$('p:empty').remove();

This works for me!


WordPress will automatically insert <p> and </p> tags which separate content breaks within a post or page. If, for some reason, you want or need to remove these, you can use either of the following code snippets.

To completely disable the wpautop filter, you can use:

remove_filter('the_content', 'wpautop');

If you still want this to function try adding a later priority value to your filter something like:

add_filter('the_content', 'removeEmptyParagraphs',99999);

Simply use CSS

p:empty {
  display: none;
}