WordPress Get Recent Comments Function

A friend asked me to put up recent comments on http://www.7achy.com

You could use a plugin, but writing your own function gives you a lot more control.

Here is a function called getRecentComments [surprise surprise!] that puts out basic information about recent comments in an unordered list.

Copy and paste the function into your theme’s function.php then call it like this:


Replace the number with as many comments as you want.
This function is verified and used on this website (bottom right) and soon on http://www.7achy.com

You can edit this function to output a lot more than what’s in there; refer to WordPress’s codex.Then edit the $commentReturn string to include whatever you want.

The funny thing is, I thought this function didn’t work when I tested it here … then I realised :'( there are no comments on my website!! *I has a sad*

One Comment on “WordPress Get Recent Comments Function

Leave a Reply

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