AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

Filter by custom fields

Topic prefix

AI Assistant
Notifications
Clear all

[Closed] How to remove empty para

3 Posts
2 Users
0 Reactions
924 Views
Posts: 8
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@osdotme)
Active Member
Joined: 4 years ago
[#26213]

Dear Support - Please look at the last answer of this forum thread https://os.me/community/books/question-related-to-kundalini-sadhana/. 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
1.9.9.1
WordPress Version
6.1

2 Replies
Tutrix
Posts: 1519
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@tutrix)
Noble Member
Joined: 6 years ago

Hi @osdotme

you can remove empty p tags

<p></p>

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"

<p>&nbsp;</p>

Tutrix
Posts: 1519
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@tutrix)
Noble Member
Joined: 6 years ago

@osdotme

you can try this jQuery code to remove the tags

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

Share: