10 Ways to Improve Comments on Your WordPress Website

Comments might not be the first thing on your mind when you’re starting a blog. But sooner or later, you will want to improve the system and make commenting process easier & better both for admins and users who decide to reply to your articles.

So, in this guide, we have decided to group together several tutorials that will help you get more out of your WordPress comments system. We will also show you some of the best alternative arrangements that can replace the standard one. If you’re just searching for something specific, here’s a quick table of contents that will help you navigate tot he right part of the tutorial:

Best comments plugins for WordPress

Once standard comment system, which is provided by WordPress, isn’t enough you have to know there are other systems used for managing your comment section. Maybe it is social networks you want to embed into your comments, more options for your users or you are trying to find a system which will make commenting more fun, you should try one of the following plugins.

Without any particular order, we will present the best comments plugins which you can easily install and start using on your site in the next few minutes.

Facebook Comment System

PRICE: Free

Facebook Comments for WordPress

If you are trying to find a way to connect your site to social networks, Facebook comments might help you. Although not very simple to install, Facebook comments will give your visitors (which are on Facebook, of course) an easy way of leaving comments on your articles.

Facebook Comments will connect you with your Facebook visitors and even make social media integration more practical while providing an option for sharing your articles at the same time.

Although this comment system is a great way of fighting spam, too, you might lose commenters who are not linked to Facebook and those who don’t want their private profile to appear on your site.

Disqus

PRICE: Free

Disquss

This is a popular Comment System which makes commenting easy and fun. Once you register an account, you can comment on any Disqus comment section on the web.

The great thing about Disqus is that you can easily add media to your comments. It’s SEO friendly as well and works in real time which means the most recent post will be shown first. This system will help you in fighting spam, providing user analytics, etc. It has a great administration control as well.

The big drawback to Disqus is a mandatory registration. If a visitor comes to your site and wants to leave a comment, one must have opened an account with Disqus. In many cases, this will not turn your visitor into a commenter. Also, if you want the full version of the plugin, you will have to pay for it.

Comments Evolved

PRICE: free

Comments Evolved

This plugin was known by the name Google+ Comments for WordPress. Now it has obviously evolved and it brings you much more than integration with Google +.

Whether it is Facebook, Google Plus, Disqus or WordPress you have, Comments Evolved for WordPress will give your users an easy way of logging in so they can post a comment.

Because of social media integration, you could easily tag your friends in the comment which is a great way of drawing more people into a conversation. It is SEO friendly which means your comments will appear in a good way for the search engines and helps you in getting more attention.

Maybe the only bad thing about this plugin is that it will separate your comments by the login method – Facebook comments will go to one tab, G+ to another, etc.

Forbid specific words to be used in comments

After you publish your first post, you will probably be on the hunt for comments. Those tiny replies that your visitors leave can be very motivating. You can open entire discussion right in the comment area, it may get more people to your site and, sometimes, you may even learn something new.

More often than not, your articles will be opened for public and that means that anyone who can access your website can also leave a comment. While this can be a good idea, public comments can contain pretty much anything. But sometimes you really can’t afford certain discussions on your site. A simple word can trigger an avalanche and you might end up having a bad reputation simply because you allowed everything and anything.

swear jar

Yeah, you can moderate your comments and disapprove those you don’t want to stick on your site, but what if you get so many comments that you can’t track all of them at once? Even if there is a fewer number of them, why wouldn’t you simply disallow specific words to be used in the first place and save yourself some time moderating profanity, to name an example?

We already showed you how to forbid usage of specific words in post titles, and today we’re about to show you how to do the same for comments. If you use the function we’re about to show you, you can put any word you want into an array and choose how to replace it. For example, you can replace profanity word with star symbols, change a word into something else or even create a link from a word.

  1. Open functions.php file
  2. Copy and paste the following code:
  3. function change_comments_words($comment) {
    $replace = array(
    
    // 'WORD TO REPLACE' => 'REPLACE WORD WITH THIS'
    
    'woodpecker' => '*****',
    'stupid' => 'smart',
    'link' => '<a href="http://link.com">link</a>'
    
    );
    $comment = str_replace(array_keys($replace), $replace, $comment);
    return $comment;
    }
    
    add_filter( 'pre_comment_content', 'change_comments_words' );
    
  4. Add as many words as you want in the array and choose how to control them
  5. Save change

That’s it. If you didn’t make any changes to the code above, your comment’s content would now behave slightly different. You can go on and try typing any of the three words we have included as an example – “woodpecker” will come out as a string of asterisk symbols, word “stupid” will be substituted with the word “smart” while a word “link” would stay the same but it would become a link leading to link.com.

Following this example, you can create a list of your own and thus control how a comment will appear on your site. If you’re already implementing this feature into your site, it would be smart (no, a function didn’t change this one) if you warned your visitors about it.

Highlight comments posted by post author

When your posts start to get recognized and you start receiving a lot of comments, it will be important to somehow highlight comments which are written by the post author. If you have ever scrolled through dozens of comments and searched for those posted by the author, you know why it would be a good idea to display author’s comments a bit differently.

Sometimes a unique avatar might be enough, but in most cases, you will want a different colored background, a slight change in font color or maybe you want a border around comments posted by the author of that post.

Highlight comments

WordPress developers already found a way to control that, so you won’t have trouble styling comments differently. In this case, all you need is a CSS class which already exists in WordPress and your task is only to change its style.

The class we’re talking about is .bypostauthor which controls the presentation of author’s comment box. By targeting the class, you can easily apply any CSS rule and create a unique comment list on your site. Still, we advise that you stay subtle and make changes as small as possible; you don’t want people to be repelled by your new comments style but only to recognize those comments made by the author.

  1. Open styles.css
  2. Copy and paste the following example:
  3. .bypostauthor {
    background-color: blue;
    }
  4. Save changes

The previous example will take the entire comment box made by the author of the post and will change its background to blue. As mentioned earlier, you can add any CSS style to the code that you want – change backgrounds, colors, borders, margins, etc. Similarly, you can style posts made by specific authors differently.

We showed you how to change the style and it’s your time to shine and to show off your designers skills. If you have created something worth showing off, leave a comment below and link us to your creation.

Highlight comments posted by specific user

In the previous few lines, we showed you an easy way of highlighting comments made by the post author. While this can add unique style to your website, more importantly, it will allow your visitors to be able to track author’s comments more easily. As you could see, creating a unique style for post author comments wasn’t that hard at all. Similarly, you can style comments posted by different users by targeting their unique usernames.

Again, you won’t have to do much; there are no functions, there’s no coding nor you’ll have to install additional plugins to change the looks of comments made by different authors. All you will have to do is add another CSS class in your style.css file and choose how you want to display comments made by that user:

  1. Open style.css
  2. Copy and paste these CSS classes:
  3. .comment-author-username {
    background-color: blue;
    }
    
    .comment-author-username2 {
    background-color: yellow;
    }
  4. Change usernames to actual users that you have registered on the site
  5. Save changes

In the previous example, we only changed the background for comments made by a specific user. Of course, you are free to create any CSS style that you want. If you are searching for something a bit more complex, see the example below.

How to target a specific user

In order to target a user, you will only have to change the “username” part of the class to the actual username from your WP database. For example, if John is an author on your site and you want his comments to be displayed with a fancy border around the comment box, this is how your CSS code would look like:

.comment-author-john {
border: 1px solid #DFDFDF;
padding: 10px;
margin-bottom: 15px;
border-radius: 10px;
-moz-border-radius: 15px;
-webkit-border-radius: 10px;
}

If you have several admins and authors on your website who tend to comment frequently and reply to user’s comments, this technique will allow you to easily differentiate their comments from the public ones. If you have browsed for authors’ comments through dozens of comments left in a post, you know how much this can actually help.

What do you think is the best of way styling each user’s comments? Subtle background color change, a bordure, something else?

Add more HTML tags in WordPress comments

After you go through this tutorial, you won’t be limiting your commenters, but you will give them more tags to work with. And you will do that through some custom coding. Don’t worry; we will give you the basic code which you have to copy and paste, as usual, and you will be choosing which tags to allow for your comments.

HTML tags in WordPress comments

Add more HTML tags in comments:

  1. Open functions.php file
  2. Copy and paste the following code:
  3. function allow_pres() {
    global $allowedtags;
    $allowedtags['pre'] = array('class'=>array());
    }
    add_action('comment_post', 'allow_pres');
    
  4. Save changes

The first function will tell WordPress that you’re a benevolent man – you give more tags to a wider audience, isn’t that great? The other one simply adds the hook which will use that functions when needed.

So far, the code adds <pre> tag in the “allowed tags” bucket. Here comes your part of coding. You can add any number of tags into the function, you will just have to know a bit of HTML to find the ones that you can actually use.

Add extra tags:

To add extra tags, use the following line:

  • $allowedtags[‘p’] = array();

For each tag, repeat the entire line of code and change the tag itself. For example:

  • $allowedtags[‘b’] = array();
  • $allowedtags[‘i’] = array();
  • $allowedtags[‘u’] = array();

If you want to go more into detail, you can use the class key as shown in the original code above. The class key allows you to specify allowed attributes to the tag as well. If you’re not sure which tags you want to be active in your comments, go through a list of HTML tags.

How to disable HTML in WordPress comments

If you have a clean website design and a lot of people commenting, those different styles of comments might mess up your layout and your site will stop being so clean, right? And that, besides other reasons, might be just a good enough incentive to completely remove HTML from your WordPress comments.

Disable HTML comments in WordPress

Disable HTML in comments:

It isn’t that hard to disable HTML in WP comments. As usual, we will give you the code which you have to copy and paste and the rest will be done by WordPress.

  1. Open functions.php file
  2. Copy and paste the following snippet:
  3. function plc_comment_post( $incoming_comment ) {
    $incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']);
    $incoming_comment['comment_content'] = str_replace( "'", '&apos;', $incoming_comment['comment_content'] );
    return( $incoming_comment );
    }
    function plc_comment_display( $comment_to_display ) {
    $comment_to_display = str_replace( '&apos;', "'", $comment_to_display );
    return $comment_to_display;
    }
    add_filter( 'preprocess_comment', 'plc_comment_post', '', 1);
    add_filter( 'comment_text', 'plc_comment_display', '', 1);
    add_filter( 'comment_text_rss', 'plc_comment_display', '', 1);
    add_filter( 'comment_excerpt', 'plc_comment_display', '', 1);
  4. Save changes

This code will tell your WordPress site to get everything in comments literally. So, if a user for example types in “<b>” tag to make his text bold, nothing will happen, except there will be a “<b>” tag displayed in a comment. The exception is single quotes which are recognized as spam by WordPress.

Now that you have made the changes, it would be nice to tell your visitor about the changes – you don’t want your commenters to be angry after they realize their HTML magic isn’t working and that their comment is full of gibberish.

If you are using default WordPress system for handling comments on your articles, you have probably noticed that you only get to edit link directly from the frontend. That means that if you want to delete or move a comment directly into the spam folder, you have to go to back to your admin panel and moderate that comment from the backend. Once you start getting new comments on a regular basis, this will be a waste of time.

There is a quick fix for this. With a simple code snippet, you can get yourself “Spam” and “Delete” links next to each comment in your articles. After you insert the code, you will only have to click on the link which will take you directly to comment moderation and make everything much faster.

  1. Open your functions.php file
  2. Copy and paste the following code:
  3. if ( ! function_exists( 'comment_mod_links' ) )
    {
    add_filter( 'edit_comment_link', 't5_comment_mod_links', 10, 2 );
    
    function comment_mod_links( $link, $id )
    {
    $template = '<a class="comment-edit-link" href="%1$s%2$s">%3$s</a>';
    $admin_url = admin_url( "comment.php?c=$id&action=" );
    
    // Mark as Spam.
    $link .= sprintf( $template, $admin_url, 'cdc&dt=spam', __( 'Spam' ) );
    
    // Delete.
    $link .= sprintf( $template, $admin_url, 'cdc', __( 'Delete' ) );
    return $link;
    }
    }
  4. Save changes

When you post a comment which contains a URL, WordPress is taught to recognize it and automatically turn URL into a link. While you can actually benefit from it, more often than not, spammers will take this function against you and link to suspicious sites directly from your comment box.

Since you haven’t installed a plugin which will deal with it, we will show you how to stop WordPress from automatically creating links out of URLs. You will need only one line of code:

  1. Open your functions.php file
  2. Copy and paste the following line:
  3. remove_filter('comment_text', 'make_clickable', 9);
  4. Save changes and enjoy links-free comment box

How can comments on your other posts help you get more page views

Whether you like them or not, comments are important to almost every blog out there. If you’re writing about something, showing pictures, videos or anything else, you probably want people to like your posts and comment on them. Also, comments may single out a post which people actually find the most interesting so you can make that post sticky, place it on your slider or simply take extra attention to it.

While you can see comment count in each post, sometimes you will need to show a number of comments for a specific post somewhere else. Instead of showing a list of most commented posts you can create a shortcode which will put a number of comments with a link to the post you have chosen.

That shortcode can be used anywhere on your site and you can easily manipulate it to show any posts’ comment count.

Alright, let’s build a shortcode:

  1. Open functions.php file
  2. Copy and paste the following code:
  3. function comments_shortcode($atts) {
    extract( shortcode_atts( array(
    'id' => ''
    ), $atts ) );
     
    $num = 0;
    $post_id = $id;
    $queried_post = get_post($post_id);
    $cc = $queried_post->comment_count;
    if( $cc == $num || $cc > 1 ) : $cc = $cc.' Comments';
    else : $cc = $cc.' Comment';
    endif;
    $permalink = get_permalink($post_id);
    return '<a href="'. $permalink . '" class="comments_link">' . $cc . '</a>';
    }
    add_shortcode('comments', 'comments_shortcode');
    
  4. Save changes
  5. Use the following shortcode in order to show comment count for a post:

[comments id=”1″]

Now that you have created a shortcode, you only have to choose where you want to show it and which post you want to analyze. You can place the shortcode in the post content, in your sidebar, header or footer or actually wherever you need to show the comment count for that specific post.

Don’t forget to change the ID to an actual post ID you want to track.

Style the comment count:

If you want to style your newly created comment count/link, you can do that with some fancy CSS code. As you may have noticed from the function, your shortcode has been given a class. Simply target the “comments_link” class and style it whatever you want to. Here’s an example.

.comments_link {
color: green;
font-size: 20px;
}

That’s it. The number of posts will be displayed in the location you have chosen, and automatic link to that post will be created. How awesome is that?

Enable usage of shortcodes in comments

Shortcodes are awesome and you easily create a custom one. They allow you to insert practically anything by simply entering a word wrapped in square brackets. And you can use shortcodes in comments, descriptions and practically anywhere on your WordPress website.

People usually use them in posts and pages, but did you know that you can also execute ones in template files or even in the Text Widget? Did you know that you can also easily add one in a button right above your Text Editor?

Since you can have your shortcodes there, maybe you were wondering if you could execute them elsewhere. The short answer is yes, you can. And in this tutorial, we’re about to show you how to enable shortcodes in comments and category, tag, and taxonomy descriptions.

Once you get used to using those little codes, you will want them everywhere. In the following lines, we’re about to show you filters you will need to add in your functions.php file in order for shortcodes to work in comments and/or descriptions.

Shortcodes in comments:

For starters, you may have placed practical things into shortcodes which your users can’t get access to. One of the examples might be good old Google Maps. If you wanted your users to be able to show something on a map right down there in your comments, and you already have a great plugin like 5sec Google Maps PRO or Google Maps Widget, why wouldn’t you allow your commenters to use them easily through shortcodes? Actually, you can do that relatively easy; all you have to do is copy and paste the following two lines into your functions.php file:

add_filter( 'comment_text', 'shortcode_unautop');
add_filter( 'comment_text', 'do_shortcode' );

Final Words

You can like or dislike them, but comments have become a standard piece of practically every website. If you haven’t shut down the entire system on your site, take some time to go through this guide and make commenting even better. You will love it, the admins will have it easier, and your users will be more likely to write something the next time they open your post.

START YOUR OWN BLOG

This guide is an introduction to mastering the art of blogging. It provides easy to follow steps to start, maintain, and grow your blog.

Read the guide

Leave a Reply

Your email address will not be published. Required fields are marked *