How To Remove The URL Field From WordPress Comments
Have you ever wanted to remove the URL field from the comments section of your website? Well if you have, then you have come to right blog post.
Before we begin and just so we are clear, listed below is what we are looking to remove.
In order to remove this field the first thing we need to do is log into your WordPress . Once inside you will then need to navigate to Appearance > Editor:
Now, we will be making code changes to two files, comments.php and function.php.
Lets begin by clicking on the Comments link. One the page refreshes you will notice that the embedded code window displays new code similar to below.
You will be looking for the code that I have highlighted. Once you find it please DO NOT delete it, instead we are going to put to forward slashes at the beginning like below:
// $fields['url'] = '<input type="text" name="url" id="url" value="'. esc_attr( $commenter['comment_author_url'] ) . '" placeholder="' . __( "Website", "Avada" ) . '" size="22" tabindex="3" class="input-website" /></div>';
Inserting the slashes allows us to comment out the code from being run by the website. I recommend doing this anytime that you are adjusting theme templates, functions or pages so that if something goes wrong you are not stuck. Simply just go back to the files where you have added the slashes and just remove them and re-save.
Next, we are going to need to add some code to the functions.php file. As you did before navigate to the the "Theme Function" or functions.php.
Ok, we need to add the following code the bottom of the page, here is the code.
// Remove url field from comment form
function disable_comment_url($fields) {
unset($fields['url']);
return $fields;
}
add_filter('comment_form_default_fields','disable_comment_url');
It should look something like this:
Once complete this is what your comment form should look like and remember if anything goes wrong just go back and remove the forward slashes.
If you have any questions feel free to ask away!
Cheers
- Dwayne
Recent Comments
25
This is brilliant, thank you! You should certainly make this a training when you can, and I will be back to 'like' it again! See you soon. :)
Thanks for the compliment and I would of made it training but I haven't been here three months yet. However, I will recreate it for training when I have that ability and then I can delete this post.
Cool! I believe soon you will be one of so many great training contributor here in WA. I really am looking forward to it. :)
See more comments
Just what I needed thank you so much and have bookmarked it just in case I forget to.
You're welcome