Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

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:

add_filter( 'comment_text', 'wptexturize'            );
add_filter( 'comment_text', 'convert_chars'          );
add_filter( 'comment_text', 'make_clickable',      9 );
add_filter( 'comment_text', 'force_balance_tags', 25 );
add_filter( 'comment_text', 'convert_smilies',    20 );
add_filter( 'comment_text', 'wpautop',            30 );

You can remove_filter( 'comment_text', 'wpautop', 30 ); to confirm, but you'll lose paragraphs entirely.

share|improve this answer
    
Yea i can confirm that its the last one. Though the paragraphs are still intact. Thanks Milo. This is the second time you help me out. Really appreciate it. Do you think WordPress is aware of this problem? –  VicePrez May 14 '11 at 22:14
    
i take that back, you're right, paragraphs are lost when removing the filter. I reverted to giving the <p> tags 0 padding. –  VicePrez May 15 '11 at 14:02

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.