Reputation: 518
In Wordpress, I cannot change HTML output of my comment form fields, but textarea works perfectly.
function set_my_comment_title( $defaults ) {
$defaults['comment_field'] = '<div class="form-group col-md-12"><textarea id="comment" name="comment" rows="3" class="form-control" placeholder="Text komentára"></textarea></div>';
$defaults['author'] = '<div class="form-group col-md-4"><input id="author" name="author" class="form-control" placeholder="Vaše meno" required="required" type="text"></div>';
$defaults['email'] = '<div class="form-group col-md-4"><input id="email" name="email" class="form-control" placeholder="Váš email" required="required" type="text"></div>';
return $defaults;
}
add_filter( 'comment_form_defaults', 'set_my_comment_title' );
Upvotes: 0
Views: 654
Reputation: 1605
Wordpress offers many filters for editing the comment elements. If you're using If you're using comment_form_defaults
the author and email fields are actually nested in a fields
array. So, the correct filter would be:
function set_my_comment_title( $defaults ) {
$defaults['comment_field'] = '<div class="form-group col-md-12"><textarea id="comment" name="comment" rows="3" class="form-control" placeholder="Text komentára"></textarea></div>';
$defaults['field']['author'] = '<div class="form-group col-md-4"><input id="author" name="author" class="form-control" placeholder="Vaše meno" required="required" type="text"></div>';
$defaults['field']['email'] = '<div class="form-group col-md-4"><input id="email" name="email" class="form-control" placeholder="Váš email" required="required" type="text"></div>';
return $defaults;
}
add_filter( 'comment_form_defaults', 'set_my_comment_title' );
Upvotes: 1