Goal:
I need to hide/disable the text-area comment field, and only display author field. I've succeeded in doing this with the code below.
Problem:
Text-area comment input is hidden, but is still required, meaning when you enter your name and hit Sign, this error is shown: Error: Please type your comment text.
from url https://theplaydesignmanifesto.org/wp-comments-post.php
Question:
How can I make the comment input field 'comment' un-required?
Environment:
- www.theplaydesignmanifesto.org (comment form at bottom)
- Wordpress 6.2
- Child theme of GeneratePress
Current code
As you can see, I attempt to unset the 'comment' field and not display it afterwards.
I've added this code in functions.php
add_filter( 'comment_form_fields', 'custom_comment_field' );
function custom_comment_field( $fields ) {
// What fields you want to control.
$comment_field = $fields['author'];
$comment_field = $fields['comment'];
// The fields you want to unset (remove).
unset($fields['author']);
unset($fields['comment']);
// Display the fields to your own taste.
// The order in which you place them will determine in what order they are displayed.
$fields['author'] = '<p class="comment-form-author"><label for="author">Name <span class="required">*</span></label><input type="text" id="author" name="author" required="required" placeholder="Name"></p>';
return $fields;
}
Code source: https://developer.wordpress.org/reference/hooks/comment_form_fields/