How To Display Recent Comments In WordPress

Comments are a way for people to discuss things and tell you what they thing about your work. It’s a good idea for you to display recent comments in WordPress to appreciate all the feedback you get from your readers. It also increase the chances of a reader commenting on your website.

WordPress has an official widget for this job, but that widget will show the names of the post, not the comment itself on the sidebar. There are also tons of plugins to display recent comments of your WordPress in the front-end of your website, but why waste your time with plugins when you can do it without a plugin?

Courtesy of WPLancer, here’s a code which will do the job. First, add following code to your current theme’s functions.php file or a site-specific plugin:

You can define number of comments, gravatar size and comment length in the first line.

Now, add following code anywhere in your WordPress theme where you want to display the recent comments:

You can also add some CSS to style the widget if you want to: