• Resolved desmenschenwerk

    (@desmenschenwerk)


    I’m using a Child Theme of the Ignite Plus Theme. Now I want to remove the “Email” an the “URL” field in the comment section. I tried adding the following function to the function.php of the Child Theme but it doesn’t fits.

    function my_fields($fields) {
      $fields['email'] = '';
      $fields['url'] = '';
      return $fields;
    }
    add_filter('comment_form_default_fields','my_fields');
Viewing 3 replies - 1 through 3 (of 3 total)
  • Theme Author Ben Sibley

    (@bensibley)

    You almost had it! You just need to add the following parameter to the filter:

    add_filter('comment_form_default_fields','my_fields', 99);

    What’s happening is that the child theme’s function needs to override the parent theme’s. However, the child theme’s functions.php file always gets called before the parent theme’s functions.php, so the parent theme’s function immediately overrides the child theme’s.

    That’s why the ’99’ parameter is added to the filter – to make sure it’s called afterwards.

    Also, make sure to turn off the name and email requirement in Settings > Discussion or no one will be able to successfully comment.

    Thread Starter desmenschenwerk

    (@desmenschenwerk)

    Thank you. Adding the ’99’ to the code resolved the problem.

    Theme Author Ben Sibley

    (@bensibley)

    You’re welcome! Glad it worked for you.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Remove fields in the comment section’ is closed to new replies.