Skip to content

Disabling URL in WordPress Comment Section

By default, WordPress allows commenters to include a URL field when posting comments. Unfortunately, this often attracts spammers who use it to drop unwanted links. On ruachost.com, you can disable the URL field in the comment section using a simple PHP function.

  • Prevents spammy backlinks in comments.
  • Keeps your comment section clean and relevant.
  • Improves SEO by reducing low‑quality outbound links.
  • Enhances user experience by focusing on genuine discussion.
  1. Log in to WordPress with an administrator account.

  2. In the dashboard, go to Appearance → Theme Editor.

  3. Select your active theme and open the functions.php file.

  4. Add the following code snippet at the end of the file:

    // Disable URL field in WordPress comment form
    function disable_comment_url_field($fields) {
    unset($fields['url']);
    return $fields;
    }
    add_filter('comment_form_default_fields', 'disable_comment_url_field');
  5. Click Update File to save changes.

  6. Refresh your site → The URL field will no longer appear in the comment form.

  • Always back up your theme files before editing.
  • Use a child theme to preserve changes during theme updates.
  • This only removes the URL field—it does not affect the comment text box or name/email fields.
  • If you later want to re‑enable the URL field, simply remove the code snippet.