Site logo

Archived topic

Remove comment url and email field, change comment label text

3 replies · Started by Joyce on October 14, 2020

Viewing posts 1–4 of 4

Hi Team,

This ticket is 1a & 1b in https://generatepress.com/forums/topic/child-theme-12/, thanks.

/inc/structure/comments.php
– remove comment url/email input field (I tried to add in function.php and also generatepress/comments.php, but it does not work.

add_filter('comment_form_default_fields', 'url_filtered');
function url_filtered($fields)
{
  if(isset($fields['url']))
   unset($fields['url']);
  return $fields;
}
add_filter('comment_form_default_fields', 'email_filtered');
function email_filtered($fields)
{
  if(isset($fields['email']))
   unset($fields['email']);
  return $fields;
}

/inc/structure/comments.php
– change text (leave a comment, Post Comment) and author label

$defaults['title_reply'] = apply_filters( 'generate_leave_comment', __( 'Change text-Leave a Comment', 'generatepress' ) );
$defaults['label_submit'] = apply_filters( 'generate_post_comment', __( 'Change text-Post Comment', 'generatepress' ) );
<label for="author" class="screen-reader-text">Change text-author label</label>

Hi,

For comment fields: You can try this guide out.
https://docs.generatepress.com/article/remove-e-mail-and-url-field-from-comment-form/

Your code is pretty close but perhaps doing step of from the article will help.

For label and button text: You can try these filters
For comment area label - https://docs.generatepress.com/article/generate_leave_comment/
For button - https://docs.generatepress.com/article/generate_post_comment/

Example:

add_filter( 'generate_leave_comment', function () {
    return 'Comment area text here';
} );
add_filter( 'generate_post_comment',function () {
    return 'Post comment button text here';
} );

Thanks Elvin, I added in the child theme function.php, it works fine, thanks.

Nice one. No problem. :)

This archived topic is closed to new replies.