Code to remove Website URL from Comments


Code to remove Website URL option from any Comments on your Website..

Many website owners prefer not to show the URL option in the comments section of their website.

The main reason is to try to stop spam, as many spammers just use that to push their own website address.

These are how a comment box may look like, with and without the Website URL option.

Comment Box change Website option

To change it from the first option, the default setting with the Website box available, to the second option, with the Website box removed, is a simple change to the functions.php code for your website.

It is important NOT to change the main functions.php code, as this will revert to default whenever your theme is updated by WordPress.

I suggest to use ‘Child Theme Configurator’, by Lilaea Media [https://wordpress.org/plugins/child-theme-configurator]
to create a child theme, if one is not already in use.

Edit the functions.php file in your CHILD THEME, by adding this code at the end of that file :

// Remove Website from Comments Field
add_filter('comment_form_default_fields', 'unset_url_field');
function unset_url_field($fields){
if(isset($fields['url']))
unset($fields['url']);
return $fields;
}
// END Remove Website from Comments Field

As always, take a backup of the file being changed before any changes.

This is an example of my functions.php after doing these changes, from line 25 to 32 in this example.

Comment Box changes in functions-php

This is the Child Theme Configurator that I used to create the Child theme.

Child Theme Configurator by Lilea Media


94.1 - 806,379
DreamHost

Scroll down for Comments
0 0 votes
Article Rating
Subscribe
Notify of

This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x