500 posts Keep Walking
  • Trendsetter
  • 4 Years of Membership
  • Elite Author
  • Author Level 9
+5 more
UXbarn
says

Hi,

I’m having an annoying problem with auto p tag that wraps around the shortcode. I’ve searched for many ways to solve this but I’m not sure which one is valid and can be accepted.

I’m currently using this:
add_filter('the_content', 'do_shortcode', 7);

But it only works for some cases. “p” tag is still there on some element, don’t know why.

Then I’ve found this:
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');

This one actually works. It can solve my problem but I think I used to read from some where that it would not be accepted? Not sure if I’m wrong…

Could you guys advise what solution are you using and valid for this case?

Thanks!

1565 posts
  • Affiliate Level 1
  • Author Level 5
  • Collector Level 2
  • Featured Author
+2 more
OriginalEXE
says
500 posts Keep Walking
  • Trendsetter
  • 4 Years of Membership
  • Elite Author
  • Author Level 9
+5 more
UXbarn
says

Thanks @OriginalEXE! Will try that. :)

by
by
by
by
by
by