How to remove website URL field from WordPress comment?

remove website URL field from WordPress commentThere are following methods to remove URL field from comments.

  1. Using CSS
  2. Editing function.php file
  3. Editing comment.php file.

Method 1: Remove website URL field from WordPress comment using CSS trick.

  1. Open new browser. Don’t use the same browser where you are logged in to WordPress dashboard.
  2. Open any post of your website from new browser.
  3. Scroll till you see comment section.
  4. Right click on website field —>inspect element. You will see HTML code for this field.
    find html code of content
  5. Basic syntax of HTML element is <element attribute1=”value” attribute2=”value”>
    The HTML code of comment fields is depend upon theme. HTML code of website URL field for my website is
    <input placeholder=”Website” id=”url” name=”url” type=”text” value=”” size=”30″>
  6. You will see id or class or both as an attributes along with values. Note down values of id or class attributes.
  7. Now CSS part will come into picture.
  8. We are going to hide Website URL field by using {visibility: hidden;} by using id selector or class selector as per requirement.HTML code of website URL field for my website contain id attibute. Hence I will use id selector. To hide URL field of my comment box I will write
    #url{visibility: hidden;}
    or I can also write input#url{visibility: hidden;}But sometimes HTML snippet of website URL field contain class attribute instead of ID attribute then you can use class selector.
  9. Where to write CSS code?You can write CSS code in Edit CSS file.
    Visit Dashboard –> Appearance –> Edit CSS.
    I will write #url{visibility: hidden;} in Edit CSS file.CSS editor

Method 2:Remove website URL field from WordPress comment by Editing function.php file.

  1. Access Dashboard–>Appearance–>Edit.
  2. Find and access function.php.
  3. Add following code in function.php file
    function alter_comment_form_fields($fields){
    $fields[‘url’] = ”; //removes website field
    return $fields;
  4. Save the function.php file.
    function.php file

Method 3: Remove website URL field from WordPress comment by Editing comment.php file.

Note: Before using this method please take backup of your website. This methods needs people who understand coding.

  1. Access Dashboard–>Appearance–>Edit.
  2. Find and access comment.php file.
  3. Comment.php file is also based on theme. Every theme contain its own comment.php file.
  4. You need to understand code. You need to find that code which is responsible for website URL field.
  5. Use PHP comments /*  */ to disable that code.
    See the following code and look how I used PHP comment.‘author’ => ‘<input placeholder=”‘ . __( ‘Name’,’generate’ ) . ‘ *” id=”author” name=”author” type=”text” value=”‘ . esc_attr( $commenter[‘comment_author’] ) . ‘” size=”30″ />’,
    ’email’ => ‘<input placeholder=”‘ . __( ‘Email’,’generate’ ) . ‘ *” id=”email” name=”email” type=”text” value=”‘ . esc_attr( $commenter[‘comment_author_email’] ) . ‘” size=”30″ />’,
    /*’url’ => ‘<input placeholder=”‘ . __( ‘Website’,’generate’ ) . ‘” id=”url” name=”url” type=”text” value=”‘ . esc_attr( $commenter[‘comment_author_url’] ) . ‘” size=”30″ />’,*/
  6. Save comment.php file.
    Comments php file