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

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;
}
  • Okay, thanks! And how can I edit the label, the <texarea> etc.? – Nitzki Aug 8 '12 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 Aug 8 '12 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 Aug 8 '12 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 Aug 8 '12 at 13:21
  • Oh, yes. Sorry, I’m betriebsblind. And thanks a lot! – Nitzki Aug 9 '12 at 10:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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