Im not sure if you guys have encountered this problem, but WordPress appends empty <p>
tags before and after the body of text from the comment_text()
function.
Strangely, when you echo get_comment_text()
or echo $comment->comment_content
(same thing) the empty <p>
tags disappear before and after the body of text.
This is entirely exclusive to a call to comment_text()
. If you’d like to recreate it the problem, give your <p>
tags top and bottom padding.
Anyway to fix this?
If you look in
wp-includes/default-filters.php
you’ll see all of the functions each comment is run through before it’s output. I’d guess it’s the last one, wpautop, which adds p tags in place of line breaks:You can
remove_filter( 'comment_text', 'wpautop', 30 );
to confirm, but you’ll lose paragraphs entirely.