// Remove empty p tags for custom shortcodes add_filter('the_content', 'op_content_filter'); function op_content_filter($content) { // array of custom shortcodes requiring the fix $block = join('|',array('shortcode1')); // opening tag $rep = preg_replace("/(

)?\[($block)(\s[^\]]+)?\](<\/p>|
)?/","[$2$3]",$content); // closing tag $rep = preg_replace("/(

)?\[\/($block)](<\/p>|
)?/","[/$2]",$rep); return $rep; }