Clear all

Script How to remove empty para

3 Posts
2 Users
Posts: 8
Topic starter
Active Member
Joined: 1 year ago

Dear Support - Please look at the last answer of this forum thread There are some empty lines injected by unwanted <p> tags. This happens if someone presses enter multiple times while writing their responses.

We want to remove such empty paras while displaying the content on our forum. Could you advice what filter or setting we need to use for the same.

Thanks for your help.

wpForo Version
WordPress Version
2 Replies
Posts: 941
Noble Member
Joined: 3 years ago

Hi @osdotme

you can remove empty p tags


with this css code

#wpforo #wpforo-wrap .wpforo-post .wpforo-post-content p:empty {display: none;}

but the p tags in your example post are not empty
they contain the html character for "no-break space"

Posts: 941
Noble Member
Joined: 3 years ago


you can try this jQuery code to remove the tags

add_action( 'wp_head', function () { ?>
jQuery(document).ready(function($) {
   $('.wpforo-post-content p').each(function() {
    var $this = $(this);
    if($this.html().replace(/\s|&nbsp;/g, '').length == 0)
<?php } );