2

I’m using the T5 Comment Textarea On Top-Plugin for the comment_field. I’m a newbie to wordpress. So I don’t know, how can i edit the Style of the comment_field or edit the Label? Usually I would put in the array of comment_form in my comments.php like this:

   'comment_field'        => '<p class="comment-form-comment">...',

But this only adds another textarea. And then I tried to add a new filter like this:

add_filter( 'comment_form_field_comment', 'my_comment_form_field_comment' );

function my_comment_form_field_comment( $comment_field ) {

    $comment_field = '<div class="comment-field-wrapper">' . $comment_field . '</div>';

    return $comment_field;
}

...no changes. Sorry, seems a little bit like Trial’n’Error. Maybe you can help me out. Would be great!

1 Answer 1

1

Change the textarea earlier than the plugin. The plugin runs with a default priority of 10, so you could use 9:

add_filter( 'comment_form_defaults', 'wpse_61103_change_textarea', 9 );

function wpse_61103_change_textarea( $fields )
{
    $fields['comment_field'] = '<div class="comment-field-wrapper">'
        . $fields['comment_field']
        . '</div>';

    return $fields;
}
5
  • Okay, thanks! And how can I edit the label, the <texarea> etc.?
    – Nitzki
    Commented Aug 8, 2012 at 10:56
  • You can do with $fields['comment_field'] what ever you want. My plugin just takes the code and moves it up, no matter what you did before.
    – fuxia
    Commented Aug 8, 2012 at 11:17
  • Sorry, I dont understand: I can wrap it up with the div. No problem. But I don't know where to put the Styles for the <textarea>. Or edit the field like this '<p class="comment-form-comment"><label for="comment">'.
    – Nitzki
    Commented Aug 8, 2012 at 13:15
  • That’s the content of $fields['comment_field']. If you write $fields['comment_field'] = 'hello' in the function above then that is the new content.
    – fuxia
    Commented Aug 8, 2012 at 13:21
  • Oh, yes. Sorry, I’m betriebsblind. And thanks a lot!
    – Nitzki
    Commented Aug 9, 2012 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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