How to Highlight New Comments for Returning Visitors in WordPress

0

Have you seen popular websites highlighting new comments since last visit? It is a great way to increase discussion on your site and provide users with more reasons to come back. In this article, we will show you how to highlight new comments for returning visitors on your WordPress site.

New comment highlighted in WordPress

First thing you need to do is install and activate Comments Since Last Visit plugin. The plugin is hosted on GitHub and here is how to install WordPress plugins from GitHub.

This plugin works out of the box upon activation, and there are no settings for you to configure. It will now highlight new comments since last visit with a blue background color.

How It Works?

The plugin sets a cookie in user’s browser when they visit any page on your website. On their next visit, it matches cookie with the comment dates and adds a CSS class new-comment to comments posted after the cookie date.

You can override the default CSS in your theme’s stylesheet. For example, you can use this CSS code as a starting point.

 .new-comment:before { content: 'New'; background: #FF000A; color: #FFF; padding: 5px; /* min-width: 500px; */ border: 1px solid #C2C2C2; border-radius: 5px; font-weight: bold; position: relative; top: 10px; margin-left: 10px; }  .new-comment { background-color: #F0FBFF; }

If comments are important for your website, and you get a lot of comments, then you would probably want to display newer comments first. This will ensure that returning visitors get to see new comments without scrolling down too much. See our guide on how to rearrange comments in WordPress.

That’s all, we hope this article helped you highlight new comments since last visit in WordPress. You may also want to check out our tutorial on how to highlight new posts for returning visitors in WordPress. Feel free to play with the CSS to meet your needs.

 

You might also like More from author