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:
This will create a file in your weblog folder for each month, named in the format of<MTArchiveDate format="%m%y">.incMMYY.inc. - Category:
This will create a file in your weblog folder for each category, named in the format of<MTArchiveCategory dirify="1">.inccategory_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.


