HackingUniversity - Hacks . Tricks . How-To's

09 March 2013

Removing Website Field from Wordpress Comment Form

wordpress-logoBlogger's love people to comment on their post's and article's to suggest them something new, maybe they can figure out some bugs in their post and they wanna share that stuff with the admin, or they just wanna appreciate the way that person has written that post, but that same thing arises a problem in this blogging culture spamming, so people just adds their website so that they get a do-follow backlink or maybe if the author has no-follow they still just spam like they do not know, so today I will show you an easy way to get rid of website field from your comment form on your wordpress blog.

remove-website-field

So now there are two ways you can remove the website field the one is by pasting few scripted lines of code into your functions.php file that will get rid of that that field, the another easy way is to hide it using display:none CSS property, well I am going to show you both you can use the one that feel's confortable.

#1. Removing Website Field using functions.php

So now just visit your Wordpress blog and open the functions.php file, well I do not have a detailed instructions how to do so so you need to do it yourself, so now after you have opened it just paste the below code into it. So now after you have paste it just save your file and check if its is working or not.

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

For Genesis Framework Users

Well if you are using genesis framework then you might need to use the below code. So just open your functions.php file and paste below code into it.

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

#2. Hiding Website Field using CSS

Well you can easily hide your website field using CSS as I have mentioned above, so if you are using Thesis theme's below code will work just perfect. So in your CSS style sheets add below CSS and save them up.

.custom #commentform input[name="url"],  .custom #commentform label[for="url"] {display:none}