0

i have a strange problem with altering comment text field in single post.

I've created $fields = array(). Inside this array, besides other fields, I've also added:

'comment_field' => '<p class="comment-form-comment"><label for="comment">' . _x( 'New Label', 'noun' ) . '</label><br /><textarea id="comment" name="comment" aria-required="true"></textarea></p>'`,

based on Wordpress documentation.

I expected from WP to override current Comment field with mine, but instead it just displayed the one i added in code and kept the old one.

Does anybody have any idea why the system is behaving like this?

Thanks

  • 1
    Can we see the entire function call? It's not 100% clear what you're doing from just a snippet of an array, I'm assuming this is in a single.php? Which function are you passing this parameter to? – Tom J Nowell Jul 17 '18 at 16:57
  • Hi Tom, nope it's inside comments.php, but i solved the issue. Actually, comment_field should be outside the $fields array. It is treated separately from the group of other fields. So, when i call comment_form(), i have to pass $fields array as one argument and then comment_field as another one. This way the system will override the default comment field. – Veljko Simovic Jul 18 '18 at 8:33
  • Can you post your answer as the answer below? – Tom J Nowell Jul 18 '18 at 11:53
0

Actually, comment_field should be outside the $fields array. It is treated separately from the group of other fields. So, when i call comment_form(), i have to pass $fields array as one argument and then comment_field as another one. This way the system will override the default comment field.

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.