WordPress empty P in shortcode issue

January 26, 2012 by fMajakovskij

After hours of browsing and testing to find out a definitive solution about the annoying empty html paragraph tag in shortcode, I found this absolutely smart and easy solution that just works!


add_filter('the_content', 'shortcode_empty_paragraph_fix');
function shortcode_empty_paragraph_fix($content)
{
$array = array (
'<p>[' => '[',
']</p>' => ']',
']<br />' => ']'
);

$content = strtr($content, $array);

return $content;
}

Speechless….

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>