97 posts
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Made it to the Authors' Hall of Fame
  • Located in Finland
+4 more
Smuliii says

Maybe I just don’t know how to use WP editor but for some reason Wordpress adds unwanted paragraph tag. The odd thing is that this empty p tag won’t show up in Firefox and IE but every other browsers show it and screw up the page.

Editor:
[box]
<h4>Title</h4>
<p>Lorem ipsum..</p>
[/box]
Faulty Browser:
<div class="box">
<p></p>
<h4>Title</h4>
<p>Lorem ipsum..</p>
</div>
1950 posts Do the Needful
  • Has sold $125,000+ on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Has been part of the Envato Community for over 4 years
  • Has referred 10+ members
+10 more
JamiGibbs says

So is [box] a shortcode you’re using? What does the function look like for the shortcode?

409 posts
  • Has been part of the Envato Community for over 4 years
  • Sells items exclusively on Envato Market
  • Located in India
Dhruv says

Add this in your theme’s functions.php file

remove_filter('the_content', 'wpautop');

Hopefully this will work. :D

97 posts
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Made it to the Authors' Hall of Fame
  • Located in Finland
+4 more
Smuliii says
Add this in your theme’s functions.php file remove_filter('the_content', 'wpautop'); Hopefully this will work. :D

This totally worked! Many thanks! :)

709 posts
  • Has referred 10+ members
  • Has sold $10,000+ on Envato Market
  • Has been a beta tester for an Envato feature
  • Has collected 10+ items on Envato Market
+2 more
ChillThemes says
function remove_wpautop( $content ) { 
    $content = do_shortcode( shortcode_unautop( $content ) ); 
    $content = preg_replace( '#^<\/p>|^<br \/>|<p>$#', '', $content );
    return $content;
}
</p>

You’d use it like this:

remove_wpautop($content)
438 posts
  • Has been part of the Envato Community for over 4 years
  • Sells items exclusively on Envato Market
  • Located in United States
christopherjon says

wouldn’t that code remove the formating for all post content or am I missing something?

I just slap

$content = preg_replace(’#^<\/p>|

$#’, ’’, $content);

into the shortcod function before the return and it does the trick.

1029 posts
  • Has referred 500+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 50+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+6 more
ThemeBlvd says

If you’re building a theme, you don’t want to really strip out the user’s ability to use WordPress’s auto formatting. One thing you can do is create a shortcode your buyers can use to allow them to temporarily escape auto formatting.

See #9 on this post:

http://www.catswhocode.com/blog/10-incredibly-cool-wordpress-shortcodes

So, using the above example you’d do:

[raw]

[box]
<h4>Title</h4>
<p>Lorem ipsum..</p>
[/box]

[box]
<h4>Title</h4>
<p>Lorem ipsum..</p>
[/box]

[box]
<h4>Title</h4>
<p>Lorem ipsum..</p>
[/box]

[/raw]
97 posts
  • Sells items exclusively on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
  • Made it to the Authors' Hall of Fame
  • Located in Finland
+4 more
Smuliii says
If you’re building a theme, you don’t want to really strip out the user’s ability to use WordPress’s auto formatting. One thing you can do is create a shortcode your buyers can use to allow them to temporarily escape auto formatting.

Yep, this seems to be best solution. Thanks.

1 post
  • Has been part of the Envato Community for over 2 years
  • Has collected 10+ items on Envato Market
swizzmagik says

This worked for me as well! Thanks a million!

90 posts
  • Has referred 200+ members
  • Has sold $500,000+ on Envato Market
  • Has collected 100+ items on Envato Market
  • Elite Author: Sold more than $75,000 on Envato Market
+5 more
Net-Labs says

Wow, removing autop is a sure way to make a few enemies. Unfortunately with removing the p tag, it also remove a lot of plugins ability to function properly.

Ive shifted between a few solutions over the last year or two, and none of them is perfect, but the one giving me most joy at present is listed below:

function croma_remove_empty_p($content) {   
    $array = array (
        '<p>[' => '[', 
        ']</p>' => ']', 
        ']<br />' => ']',
        ']<br />' => ']'
    );
    $content = strtr($content, $array);
        return $content;
}
add_filter('the_content', 'croma_remove_empty_p', 10);

Helpful Information

  • Please read our community guidelines. Self promotion and discussion of piracy is not allowed.
  • Open a support ticket if you would like specific help with your account, deposits or purchases.
  • Item Support by authors is optional and may vary. Please see the Support tab on each item page.

Most of all, enjoy your time here. Thank you for being a valued Envato community member.

Post Reply

Format your entry with some basic HTML. Read the Full Details, or here is a refresher:

<strong></strong> to make things bold
<em></em> to emphasize
<ul><li> or <ol><li> to make lists
<h3> or <h4> to make headings
<pre></pre> for code blocks
<code></code> for a few words of code
<a></a> for links
<img> to paste in an image (it'll need to be hosted somewhere else though)
<blockquote></blockquote> to quote somebody

:grin: :shocked: :cry: Complete List of Smiley Codes

by
by
by
by
by
by