Comments are very important in a blog. By default, it is disabled in WordPress. But one of the first things that are done is enabling comments along with a comment spam fighting plugin like Akismet. Comments add the interactivity to a blog. Users will be able to give feedback or discuss directly below the articles. Users can also interact and help each other out with the help of comments.
There are many benefits of having a commenting system. But along with comments we have to deal with spam. While most spam is caught by Akismet, some comments will still have links that are usually not desired. Additionally, WordPress converts text links automatically to hyperlinks. That means if someone writes www.website.com in the comments, HTML code is automatically added to make the text link clickable. The links have a ‘rel=nofollow’ tag which means that search engines do not pass the link value when it comes to search engine rankings.
However, most site admins would want the links in their comments to not be clickable. Otherwise commenters will post links that are undesired, like links to competitor websites.
Making Links Un-clickable in Comments
Removing Automatic Text Links
To make the links appear as text and only text, follow these simple steps:
- Access functions.php file present in the theme’s folder i.e. /wp-content/themes/<your-theme>/functions.php
- Add this line:
[php]remove_filter(‘comment_text’, ‘make_clickable’, 9);[/php]
The above line will only remove those links that are typed as a text, like http://www.google.com. It will work on previously placed link texts as well.
Removing HTML Hyperlinking Tags
Users will still be able to use the <a href> HTML tag to add links while commenting. To disable <a href> HTML tag, add the following lines to the same old theme’s function.php file:
[php]add_filter(‘pre_comment_content’, ‘remove_comment_links’);
function remove_comment_links($comment) {
global $allowedtags;
$tags = $allowedtags;
unset($tags[‘a’]);
$comment = addslashes(wp_kses(stripslashes($comment), $tags));
return $comment;
}[/php]
Notes:
- This second function will only remove the hyper linking html tags from future comments.
- Add these lines of code after <?php or before the ?> tag in the content of functions.php.
- If it isn’t already present, then create a functions.php file in your active theme’s folder.
Disable Link Input Field in Comments
In the comment field, users can input their name, email and website along with a comment. You can remove the website field as well.
1. Editing functions.php
If you want to remove the comment field then the best way to do it is again by editing the functions.php file present in the currently active WordPress theme.
- Navigate to /wp-content/themes/<your-theme-name>/ using a file manager or FTP.
- Edit the functions.php file using a text editor and add the following lines of code:
[php]add_filter(‘comment_form_default_fields’,’disable_comment_link’);
function disable_comment_link($inputs) {
unset($inputs[‘url’]);
return $inputs;
}[/php]
2. Using a Plugin
There are a couple of plugins that will disable the URL field in WordPress comments. Here are some of them:
Once installed and activated, any one of these three plugins will simply remove the user URL field from the comments. There are no additional setups required.