491 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Won a Competition
  • Referred between 1000 and 1999 users
  • Author had a Free File of the Month
  • Author had a File in an Envato Bundle
  • Bought between 10 and 49 items
+3 more
pixelentity says

care to share the full code. did you add it in a filter function?
yeah, same as quoted example, inside a “the_content” filter

BF

439 posts
  • Bought between 50 and 99 items
  • Europe
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 5 000 and 10 000 dollars
Pixelous says

Bookmarked this.

707 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 10 and 49 items
  • Has been a member for 5-6 years
  • Exclusive Author
  • Envato Studio (Microlancer) Beta Tester
ChillThemes says
307 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Exclusive Author
  • Envato Studio (Microlancer) Beta Tester
  • United States
  • Has been a member for 4-5 years
  • Bought between 10 and 49 items
  • Referred between 1 and 9 users
brainbuzzmedia says

I still haven’t found a solution to this after looking through about 5 threads. I am using what I think Pixelentity meant with his last two replies but it isn’t removing the extra junk. Is this code incorrect Pixelentity?

     add_filter('the_content', 'shortcode_empty_paragraph_fix');

    function shortcode_empty_paragraph_fix($content)
    {   
    $block = join("|",array("col"));
    // opening tag
    $rep = preg_replace("/(<p>)?\[($block)(\s[^\]]+)?\](<\/p>|<br />)?/","[$2$3]",$content);
    // closing tag
    $rep = preg_replace("/(</p><p>)?\[\/($block)](<\/p>|<br />)/","[/$2]",$rep);
    return $rep;
    }
</p>
(without the weird end p tag that tf adds)
491 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Won a Competition
  • Referred between 1000 and 1999 users
  • Author had a Free File of the Month
  • Author had a File in an Envato Bundle
  • Bought between 10 and 49 items
+3 more
pixelentity says

I am using what I think Pixelentity meant with his last two replies but it isn’t removing the extra junk. Is this code incorrect Pixelentity?
yes but you need to list in the block array all your block shortcodes like columns, tabs, accordions and similar

$block = join("|",array("shortcode1","shortcode2","shortcode3"));
1 post
  • Bought between 10 and 49 items
  • Has been a member for 2-3 years
murderbydeath says

Erm…how about just this -

p:empty { display: none; }

Or, to cover your bases and hide all empty elements,

*:empty { display: none; }

385 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Has been a member for 4-5 years
  • United Kingdom
  • Referred between 100 and 199 users
  • Bought between 10 and 49 items
  • Exclusive Author
EugeneO says

Erm…how about just this -

p:empty { display: none; }

Or, to cover your bases and hide all empty elements,

*:empty { display: none; }
None of the PHP solutions have worked consistently for me so I have started using this CSS solution. It works well so far but I’ll have to see if the reviewers say anything about it when I upload my next item.
707 posts
  • Sold between 10 000 and 50 000 dollars
  • Referred between 10 and 49 users
  • Bought between 10 and 49 items
  • Has been a member for 5-6 years
  • Exclusive Author
  • Envato Studio (Microlancer) Beta Tester
ChillThemes says

I’ve used this in the past, when I use to bundle shortcodes in my themes and it worked great. They shouldn’t reject you for using these functions, they don’t modify the_content.

function prefix_remove_wpautop( $content ) {
    $content = do_shortcode( shortcode_unautop( $content ) );
    $content = preg_replace( '#^<\/p>|^<br />|<p>$#', '', $content );
    return $content;
}
</p>

OR

function prefix_remove_wpautop( $content ) {
    $content = trim( wpautop( do_shortcode( $content ) ) );
    if ( substr( $content, 0, 4 ) == '')
        $content = substr( $content, 4 );
    if ( substr( $content, -3, 3 ) == '<p>')
        $content = substr( $content, 0, -3);
    $content = str_replace( array( '</p><p></p>' ), '', $content );
    return $content;
}

Usage:

return prefix_remove_wpautop( $content );
39 posts
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Europe
  • Exclusive Author
  • Has been a member for 2-3 years
  • Envato Studio (Microlancer) Beta Tester
  • Bought between 10 and 49 items
  • Referred between 50 and 99 users
DeliciousThemes says

For what it’s worth, I had been following misguided advice from tutorials that should be taken offline before I ran across this old but useful post by Viper007Bond: http://www.viper007bond.com/2009/11/22/wordpress-code-earlier-shortcodes/ Preprocessing shortcodes that output user-supplied content end up showing correctly without all the annoying paragraph and break formatting issues while third-party plugin shortcodes continue to function normally. I only implemented this recently and so far so good. Anybody have a reason that this is not a good solution?

This is what I`m using too. So far so good. I can`t believe how such a big issue can be solved by only adding a number at the end of the add_filter('the_content', 'do_shortcode');.

add_filter('the_content', 'do_shortcode', 7);
1 post
  • Bought between 10 and 49 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • United Kingdom
ajowell100 says
All
function clean_shortcodes($content) {   
    $array = array (
        '<p>[' => '[', 
        ']</p>' => ']',
        '<p><span>[' => '[', 
        ']</span></p>' => ']', 
        ']<br />' => ']'
    );

    $content = strtr($content, $array);
    return $content;
}
add_filter('the_content', 'clean_shortcodes');
Works for me.
by
by
by
by
by
by