How to disable URL in WordPress comment section

WordPress comment section is often tagged with spam URL links. This article gives you the steps to remove these URLs from the comment section with a simple php function.

Configuring the theme file to remove URL from comment section

Always perform a backup before you make any changes to the theme files. If you break any codes, it will be easier for you to revert your site to its last good known state. Alternatively, you could also create a child theme. Read this link on how to create a child theme: https://www.a2hosting.com/blog/wordpress-child-theme/ 

To edit your Theme setting file to disable URL in the comments section , follow the steps below :

  1. Log in to your WordPress site with an administrator account.
  2. On the Dashboard in the left sidebar, click Appearance, and then click Theme Editor:

    You can always use the default editor for the theme. This article will use the Theme Editor Plugin to edit the theme files.Refer to this link to install Theme Editor plugin:  https://wordpress.org/plugins/theme-editor/
  3. On the Theme Editor, select the Theme you want to edit from the dropdown: 

    You will not be able to roll back to your earlier Theme configuration after any edits. It is recommended to save the Theme file before proceeding with the edits
  4. The files for this selected theme is listed on the right column under Theme Files
  5. Click on the file named “functions.php”:

  6. Insert the following code at the end of the functions.php file:

     

    function disable_comment_URL_field($fields) {
    
    unset($fields['url']);
    
    return $fields;
    
    }
    
    add_filter('comment_form_default_fields','disable_comment_URL_field');
    
  7. Save the file and exit the editor. 

 

More Information

For more information about the please visit the following link:https://wordpress.org/plugins/theme-editor/

Get WordPress Hosting

Article Details

Other Articles in This Category

Show More

Did you find this article helpful? Then you'll love our support. Experience the A2 Hosting difference today and get a pre-secured, pre-optimized website. Check out our web hosting plans today.

We use cookies to personalize the website for you and to analyze the use of our website. You consent to this by clicking on "I consent" or by continuing your use of this website. Further information about cookies can be found in our Privacy Policy.