June 10, 2004

Category Customizations

One area where plugins have greatly enhanced MT functionality is in categories. Here's a list of some of the things you can do:

How to exclude entries of certain categories from lists of entries.

Say you want to list out your 20 most recent entries in your sidebar, except for the entries in the Special Announcements category. This is easy enough to do with the Exclude Categories plugin. The code would look like this:

<MTEntriesExCat category="Special Announcements" lastn="20">
<a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a><br />

How to list entries only from certain categories.

This trick doesn't require a plugin at all. Just add the category attribute after the MTEntries tag like so:

<MTEntries category="Special Announcements" lastn="20">
<a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a><br />


<MTEntries category="Special Announcements AND Music" lastn="20">
<a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a><br />

How to show Previous and Next Entry within a category.

On your individual entry archive pages MT by default lists the previous and next entries from your blog. Suppose you only want to show the previous and next entries within that entry's primary category, like I've done with my photo album example? You'll need to install Phil Ringnalda's PreviousNextInCategory plugin. The code will look like this:

<a href="<$MTEntryPermalink$>">&laquo; <$MTEntryTitle$></a> |
<a href="<$MTEntryPermalink archive_type="Category"$>"><$MTEntryCategory$></a>
| <a href="<$MTEntryPermalink$>"><$MTEntryTitle$> &raquo;</a>

How to exclude a category from a list of categories.

The Filter Categories plugin helps you to include or exclude certain categories from a list of categories.

How to create a link on your Individual Entry to the Category page of the primary category of that entry.

This shouldn't be difficult, but it sure had me stumped trying to figure out how to do it. Thanks to Support Forum contributor Maddy for the clue.

<a href="<MTEntryLink archive_type="Category">"><MTEntryCategory></a>

How to have entries from different categories display different styles.

Say you want the entries on your main blog page to show a different background color depending on what primary category they are in? To do this first create additional classes in your stylesheet with the styling for those categories. For example, if you wanted your entries in your "news" category to be in a green box, add this element to your stylsheet:

.news {
padding: 10px 10px 10px 10px;
background-color: #effbdb;
border: solid 1px #7c9e40;

Then in your Main Index template, add the div class
<div class="<$MTEntryCategory$>">
just after the MTEntries tag. Close the tag by adding a </div> before the closing MTEntries tag. As long as your stylesheet class name and your category name is the same, you should be able add unique styles to your different categories. Many thanks to LMT reader Mariann for this tip!

Movable Type Manual section on category tags
MT Forums thread on how to add category specific images to your category pages
Category Icons - Arvind from Movalog shows how to use specific icons to represent categories.
Per-Category Individual Entry Archive templates - how to have different Individual Entry templates depending on the category, from Shelley of The Girlie Matters.
Sorting categories non-alphabetically - a tutorial using Regex from Movable Type Weblog.

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

Posted by Elise Bauer on June 10, 2004 to Categories
Comments(5) | Email to a friend | Printer-friendly version


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

» Slide shows now working from Ted
I just love the blog community - it is so easy to find a helpful tutorial like Learning Movable Type: Category Customizations. Now in my photoblog, the slide shows work - instead of being taken to the next or previous......[read more]

Tracked: February 26, 2005 08:02 AM


With the new release of SubCategories, I tried to make sure the documentation for it this time around was much better than the previous versions. To that end, there is a documentation page on my wiki for SubCategories ( http://wiki.rayners.org/plugins/SubCategories ). Hopefully that will help out anybody new to the plugin. If you find it lacking or have any suggestions, feedback is always appreciated.

Does anyone know how to make a page look different for each category? For example maybe put a different header image for each category?

Other John - See the link listed in the tutorial for the MT Forums thread on that subject.

Multi-category classification -

Does anyone have docs on how to use mulitple category classification on MT? Creating a blog, and would like to have the ability to assign multiple categories to a single entry

Danielle - you can assign multiple categories to an entry. Once you've saved an entry in your entry edit window, look at the upper left side, right above the entry body window. Underneath the indicator of the primary category is a link to assign multiple categories. Clicking on that link will open up a new window where you can select additional categories for that entry. Select your new categories and select save. Then select save again for the entry itself.

Comments are now closed for this entry.

Email to a friend

Email this article to:

Your email address:

Message (optional):