Displaying a “No Comment/Trackback Received Yet” Message


Published on May 16, 2005 at 7:34 PM EST
In the Tutorials category.

One of the changes I made with Scrapbook, the new site design, is to add a little “no comments yet” or “no TrackBacks yet” message to the entries that haven’t received any. Using a little PHP, it’s easy to do.

Below is some code to do this, using default template code as an example. The PHP is bolded to (hopefully) make it easier for you to institute on your site.

<?php if (<MTEntryCommentCount> != '0' ) { ?>

<MTComments>
<$MTCommentBody$>
<p class="posted">Posted by <$MTCommentAuthorLink default_name="Anonymous" spam_protect="1"$> at <$MTCommentDate$></p>
</MTComments>

<?php } else { ?>

<p>No comments have been posted on this entry. Be the first!</p>

<?php } ?>

Doing the same thing to TrackBacks is similar:

<?php if (<MTEntryTrackbackCount> != '0' ) { ?>

<p>Listed below are links to weblogs that reference <a href="<$MTEntryPermalink$>">'<$MTEntryTitle$>'</a> from <a href="<$MTBlogURL$>"><$MTBlogName encode_html="1"$></a>.</p>>

<MTPings>
<p id="p<$MTPingID$>">
<a href="<$MTPingURL$>"><$MTPingTitle$></a> from <$MTPingBlogName encode_html="1"$><br />
<$MTPingExcerpt$> <a href="<$MTPingURL$>">[Read More]</a>
</p>
<p class="posted">Tracked on <$MTPingDate$></p>
</MTPings>

<?php } else { ?>

<p>No TrackBack pings have been received on this entry. Be the first!</p>

<?php } ?>

That’s all there is to it!