The Movable Type Knowledge Base

List Recent Comments

Question

How can I list recent comments to my blog on my Main Index page?

Answer

There are two basic variations on this type of display.

Via MTComments tag

You can put the following into your Main Index Template:

<MTComments lastn="6" sort_order="descend">
<p><$MTCommentAuthor$> said:<br />
<$MTCommentBody$></p>
</MTComments>

This will display the 6 most recent comments made on any of the entries in your weblog, and sort them in reverse chronological order (most recent first).

Via MTEntries tag

Another variation is to use the recently_commented_on attribute for the MTEntries tag:

<MTEntries recently_commented_on="6">
<MTComments lastn="1">
<p><$MTCommentAuthor$> said:<br />
<$MTCommentBody$></p>
</MTComments>
</MTEntries>

This will display the 6 most recently commented-on entries. Each entry will appear in the list only once, so if, for example, a comment is posted to Entry A, then a comment to Entry B, then another to Entry A, there will be two entries displayed: Entry A, then Entry B.

Submit Feedback on This Article

Your comments on how we can improve this article are appreciated; but please do not use the feedback form to submit support requests or questions. We will not respond to or publish such queries submitted through this form. If you have a technical question or problem, visit Movable Type Support.

Yahoo! Small Business web hosting services

Six Apart
Makers of weblog software and services for individuals, organizations and businesses.
This website is powered by Movable Type.