Reply To: Need help with formatting posts

#529
Livemeshlivemesh
Keymaster

This is a WordPress issue when using shortcodes. Unwanted line breaks and empty paragraphs are easy to sneak in when designing your content. To help overcome this issue, try to have the following code pasted into your custom-functions.php file –

/*
Description: Fix issues when shortcodes are embedded in a block of content that is filtered by wpautop.
*/

function shortcode_empty_paragraph_fix($content) {
    $replace = array(
        '

' => '', '

[' => '[', ']

' => ']', ']
' => ']', "
\r[" => "\r[", "
\r\n[" => "\r\n[", "
\n[" => "\n[" ); $content = strtr($content, $replace); return $content; } add_filter('the_content', 'shortcode_empty_paragraph_fix');

.

Hope this helps.