Recently I needed a widget or plugin which is able to show only the comments from th current category. It seems that this kind of widget is not very common, so I checked the code from several themes I used in the past and also some plugin. The function below should do the trick, place this function into your functions.php file (theme directory) and add the function into your sidebar.

Features included:

  • Shortened comments snippet
  • the comment author’s name
  • filter by one or more category IDs
  • shorten the post title if needed
  • Show the comment date (local date format)

Inside this function another custom function is called, include that function too:

How-to use the current category ID inside that function?

The SQL statement inside the comment function is based on a plugin I found on the WordPress website.

Pin It on Pinterest

Share This

Share this post with your friends!