The Movable Type Knowledge Base

List All Entries In Same Month Or Category As Current Entry

Question

How do I show all entries from the same month or category as the current entry on an Individual Archive?

Answer

If you want a list on the Individual pages which only shows entries in the same month or category as the entry, you will need to do this with a second Archive Template and a PHP (or SSI) include.

Create The New Template

Navigate to Templates and click the Archives tab1. Click Create New Archive Template.

Assign the template a name of your choosing (to distinguish it from your normal Monthly or Category Archive Template). In the Template Body, enter code similar to this:

<MTEntries>
<a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a><br />
</MTEntries>

Remember to Save the template.

Add The New Archive Mapping

Navigate to Settings > Publishing, and under Archive Mappings, click Create New Archive Mapping2. ADD the new template you just created as either a Monthly or Category Archive type (depending on which type of entry listing you're wanting).

Create An Archive File Template

Set the Archive File Template for your new template under Archive Mappings3. For example:

  • Monthly:
    <MTArchiveDate format="%m%y">.inc
    This will create a file in your weblog folder for each month, named in the format of MMYY.inc.

  • Category:
    <MTArchiveCategory dirify="1">.inc
    This will create a file in your weblog folder for each category, named in the format of category_name.inc.

Insert The Include Code

Include the new listing with PHP in your Individual Entry Archive template:

  • Monthly:
    <? include ("/home/melody/public_html/archives/<MTEntryDate format="%m%y">.inc"); ?>

  • Category:
    <? include ("/home/melody/public_html/archives/<MTEntryCategory dirify="1">.inc"); ?>

The path above is just an example - you will need to use the full server path on your system which points to your archives. Look at your Site Root4 in Settings > Publishing to determine the path you should use.

Rebuild Your Archives

Select Rebuild Site. Rebuild your Individual Entry Archives, and then rebuild your Monthly (or Category) Archives.

1 In versions prior to 3.2, click Templates and scroll down to Archive-Related Templates.

2 In versions prior to 3.2, navigate to Weblog Configuration > Archive Files, and use the options under Create A New Template/Archive Type Association.

3 In versions prior to 3.2, this section is called simply Archives.

4 If you're using Advanced Archive Publishing, look at the Archive Root. In versions prior to 3.2, look at the Local Archive Path on the Weblog Configuration > Core Setup screen.

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.