Wordpress-Hide website field in comment form or make a better customization

Wordpress-Hide website field in comment form or make a better customization

Posted: 10 years ago in  PHP | Wordpress |


Wordpress has own comment system which is good enough to let user give comment. However, if you have better design, it would be great you replace it with default form.


Wordpress has own comment system which is good enough to let user give comment. However, if you have better design, it would be great you replace it with default form.

To hide the website field, I will give you tips to make it at glance ;-)

Let check your active theme. Then go to wp-content/themes/theme-name/. Comments.php is what you are looking for. There might be several cases:

  1. file does not exist in your theme-name folder: wordpress will generate the comment form using wp-includes/theme-compat/comments.php. You copy this file to wp-content/themes/theme-name then we are following steps in case 2
  2. file comments.php does exist and it use code snippet at the end of file to generate comment form:
    <?php comment_form(); ?>

    If the snippet is not present in comments.php. You will look at code that refer to URL field then...comment it out.
    In the other hand, you are good to go to step 3.

  3. Open file wp-content/themes/theme-name/functions.php and add following code to the end of file:
    add_filter('comment_form_default_fields', 'url_filtered');
    function url_filtered($fields)
    {
      if(isset($fields['url']))
       unset($fields['url']);
      return $fields;
    }

Refresh the page and contemplate your achievement. Do not forget to clear cache if you use it.