WordPress Tips: Quick Way to Remove URL Field from Comment Form
We all know that WordPress is highly customizable and can be customized up to a great extent. WordPress is also famous for a huge repository of plugins which provides you plugins for everything. What if you want to remove URL form from the comment form? This prevents automated bots to post spam links on your website. It helps your website retain the SEO Juice.
In other words:
Are you a WordPress Developer? Developing WordPress Themes? And wanted to remove URL / Website Field from WordPress Comment Form? Then you are at right place.
There are number of ways to remove URL field from WordPress comment form:
Option-1)
Remove URL text from WordPress comment form. These are default input fields:
$fields = array( 'author' => '<p class="comment-form-author"><label for="author">' . __( 'Name', 'domainreference' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="author" name="author" type="text" value="' . esc_attr( $commenter['comment_author'] ) . '" size="30"' . $aria_req . ' /></p>', 'email' => '<p class="comment-form-email"><label for="email">' . __( 'Email', 'domainreference' ) . '</label> ' . ( $req ? '<span class="required">*</span>' : '' ) . '<input id="email" name="email" type="text" value="' . esc_attr( $commenter['comment_author_email'] ) . '" size="30"' . $aria_req . ' /></p>', 'url' => '<p class="comment-form-url"><label for="url">' . __( 'Website', 'domainreference' ) . '</label>' . '<input id="url" name="url" type="text" value="' . esc_attr( $commenter['comment_author_url'] ) . '" size="30" /></p>', );
Just remove 'url' =>
field from above code.
Option-2)
Add below code to theme’s functions.php
file.
function crunchify_disable_comment_url($fields) { unset($fields['url']); return $fields; } add_filter('comment_form_default_fields','crunchify_disable_comment_url');
Option-3)
You may want to use this simple WordPress Plugin.
Option-4)
Add below code to your theme’s functions.php file.
add_filter('comment_form_field_url', '__return_false');
This code will disable URL field from WordPress comment form.
Extra Tips: How to remove all third party links from comment section?
Sometime you want to remove all spammy links your comments puts into comment. If you have comment auto approved setting on, then it won’t take more time to become your comment section as spammy links storage 🙂
Just put below code snippet into your functions.php file and all of your comment links will be disabled.
remove_filter('comment_text', 'make_clickable', 9);
Happy blogging and keep commenting!!