Get Rid of Empty

Tags in WordPress

There are a handful of things that cause this to happen. It can be a nightmare to track down and it will totally mess up your styling.

Causes

WordPress itself, page builders, and plugins. So, pretty much anything.

Go through the standard diagnosis of turning off themes and plugins. Hopefully you will find the culprit.

Fixes

Your first fix should be to take care of the plugin, theme, or setting causing it.

Next, you can try to get WordPress to stop by adding this to your functions file.

// trying to remove the nightmarish <p> being added 
remove_filter('the_content', 'wpautop'); 
remove_filter('the_excerpt', 'wpautop');

However, if it is a plugin or something else that you cannot figure out. You can heavy hand it with this bit of code. Place in in the footer and have it run once the page loads. Not ideal, but should do the trick if nothing else is working.

<!-- added to force strip out empty <p> tags that plague WordPress -->
<script>
jQuery(document).ready(function(){
	jQuery( 'p:empty' ).remove();
})	
</script>