Remove website field from WordPress comment box

by | Dec 12, 2020 | Tips, WordPress | 0 comments

As your WordPress website/blog grows, the number of spam comments would also increase. There are good anti-spam plugins services such as Akismet, Antispam Bee, etc. However, still we can see some spam comments coming in with website URLs. It’s a good idea to remove the Website field from the comment box itself.

In this post, we’ll show you how to remove the “website” field, as well as remove the word “website” from the consent checkbox and/or completely change the text of comment consent as of your choice.

Before

Codechilli - 01 codechilli remove website from comment before

After

Codechilli - 02 codechilli remove website from comment after

To achieve this, you need to add the below code snippet(s) to your website. However, editing the theme files is not a good idea. Here are our recommendations;

1. Add the snippets to your child theme’s functions.php file – If you don’t have a child-theme go with the next option. But consider having a child-theme, it’s a must for any WordPress site I would say.

2. Install snippets using Code Snippets plugin – This is one of the easiest & flexible methods of installing code snippets on WordPress. You may activate/deactivate a snippet at any time you want to. Also if you change your theme, you don’t have to add snippets again to your new child theme.

Note: Before doing any changes to your website, make sure you backup your database and/or website files.

Remove the “website” field

Add below code to your child theme’s functions.php or create a new snippet on the Code Snippets plugin.

add_filter('comment_form_default_fields', 'codechilli_unset_url_field');
function codechilli_unset_url_field($fields){
    if(isset($fields['url']))
       unset($fields['url']);
       return $fields;
}

Edit consent text

The default text that comes with WordPress is Save my name, email, and website in this browser for the next time I comment. You may add any text you wish to. Just replace the below text in line 5:

Remember my name & email in this browser for the next time I comment.
add_filter('comment_form_default_fields', 'codechilli_change_comment_consent_text');
function codechilli_change_comment_consent_text($fields)
{
    $commenter         = wp_get_current_commenter();
    $fields['cookies'] = '<p class="comment-form-cookies-consent"><input id="wp-comment-cookies-consent" name="wp-comment-cookies-consent" type="checkbox" value="yes"/>' . '<label for="wp-comment-cookies-consent">' . __('Remember my name & email in this browser for the next time I comment.') . '</label></p>';
    return $fields;
}

That’s it. Now you know how to customize the comment box. Please let us know how it works for you 😊

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *

What we do

We create brilliant digital products that help our clients get ahead and stay there.

codechilli-services-digital-marketing

Digital Marketing

We were born from digital and it remains our core capability of communication. We activate all of our studios (strategy, brand, data analytics, and technology) to work in harmony to deliver the right message to the right audience at the right time on the right platform.

codechilli-services-digital-analytics

Digital Analytics

Digital marketing thrives on data. No matter what type of site/app you have, whether it’s a large e-commerce site, a personal website, a site for a small business, or a high scale app people used to order food, it’s essential to understand how people interact with your web/app. We’re at your disposal.

codechilli-services-wordpress

Web Development

As your modern-day business card, your website is a digital biopsy of your essence. Through qualitative and quantitative research and analysis, we distill the essence of your brand and express it through user-centric design to create a bespoke digital experience.

Let's Talk

about your next project.

Share This