January 14, 2006

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="%X"$></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.

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

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.


Has this tutorial been helpful? Please consider linking to Learning Movable Type at http://learningmovabletype.com/ . Thanks!

Posted by Elise Bauer on January 14, 2006 to Beginner Tips, Categories
Comments(3) | Email to a friend | Printer-friendly version


Trackback

If you would like to send a trackback
please use the following URL: http://learningmovabletype.com/cgi-bin/mt32/mt-tb.cgi/448

Comments

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?

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

(Before posting a comment please see the Comments and Trackbacks Policy. Do you need help troubleshooting your weblog? Please post questions and requests for support at the MT Support Forums. Thanks!)




Remember Me?

(you may use HTML tags for style)

Email to a friend

Email this article to:


Your email address:


Message (optional):