« Printer-Friendly Pages | Main | Recent Comments »

Adding a "Posted to Category" Line

mtbadge-small.gif The default settings for Movable Type include category archiving. If you assign categories to your posts, you may want to include that information in the "Posted by" section underneath each entry. This is quite easy to do.

In the Main Index template, find the following block of code:

<p class="entry-footer">
<span class="post-footers">Posted by <$MTEntryAuthorDisplayName$> at <$MTEntryDate format="%"$></span> <span class="separator">|</span> <a class="permalink" href="<$MTEntryPermalink$>">Permalink</a> <MTIfCommentsActive>| <a href="<$MTEntryPermalink$>#comments">Comments (<$MTEntryCommentCount$>)</a></MTIfCommentsActive> <MTIfPingsActive>| <a href="<$MTEntryPermalink$>#trackback">TrackBacks (<$MTEntryTrackbackCount$>)</a></MTIfPingsActive>
</p>

Add the following code before the closing closing p tag of the code above.

Posted to <MTEntryCategories glue=" | ">
<a href="<$MTCategoryArchiveLink$>"><$MTCategoryLabel$>

Save and rebuild your Main Index template.

In your Individual Entry Archive Template, find the following code:

<p class="entry-footer">
<span class="post-footers">Posted by <$MTEntryAuthorDisplayName$> on <$MTEntryDate$></span> <span class="separator">|</span> <a class="permalink" href="<$MTEntryPermalink$>">Permalink</a>
</p>

Add the following code before the closing span tag or p tag of the code above.

Posted to <MTEntryCategories glue=" | ">
<a href="<$MTCategoryArchiveLink$>"><$MTCategoryLabel$>
</a></MTEntryCategories>

Save template and rebuild your files.

Comments (3)

Arvind [TypeKey Profile Page]:

If you want to show Cateogry/SubCategory relationships (eg. Parent » Sub), use this code


<MTEntryCategories glue=", ">
<MTParentCategories glue = "&raquo; ">
<a href="<$MTCategoryArchiveLink$>"
title="<$MTCategoryDescription$>"><$MTCategoryLabel$></a>
</MTParentCategories>
</MTEntryCategories>

Any idea on how you would only show subcategories?

Swift [TypeKey Profile Page]:

For the code on the individual archive template, does that only work if the archives are static? I'm using dynamic publishing for my archives, but for some reason can't get the code to work in my individual archive template.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)