
As each day passes, more and more posts are added to our blog sites. I was thinking of what if the archives will reach ten years? Well, I dont have that much number of posts, probably my blog will still survive. What I'm more concerned about is the monthly archives displayed on the sidebar. It will be displaying a very long list of months year by year. There must be some way to arrange them yearly.
I figured, there are already many MT4 bloggers who may have implemented it like Beau and his Advanced Archive Widget. Unfortunately, what i was looking is to display my yearly based archives horizontally as opposite to the one Beau has done. The main reason why i wanted to display my yearly archive horizontally is because there might be not enough room as the years go by since the list is growing sideways.
I have experiemented my version with my blog for hours and ended up displaying the yearly archive using simple methods using lists. Here is my version below:
<mt:IfArchiveTypeEnabled archive_type="Yearly">What to do?
<div class="widget-archive-yearly widget-archive widget">
<h3 class="widget-header"><$mt:ArchiveTypeLabel$> <a href="<$mt:Link template="archive_index"$>">Archives</a></h3>
<div class="widget-content">
<mt:ArchiveList type="Yearly" sort_order="descend">
<mt:ArchiveListHeader>
<ul>
</mt:ArchiveListHeader>
<li class="widget-list-item"><a href="<$MTArchiveLink$>"><b><$mt:ArchiveDate format="%Y"$></b></a><br />
<mt:ArchiveList type="Monthly" sort_order="ascend">
<span> <a href="<$MTArchiveLink$>"><$mt:ArchiveDate format="%b"$></a> </span>
</mt:ArchiveList>
</li>
<mt:ArchiveListFooter>
</ul>
</mt:ArchiveListFooter>
</mt:ArchiveList>
</div>
</div>
</mt:IfArchiveTypeEnabled>
- Create a Widget and paste the code above, save it as "Yearly Sidebar Archives" or any name you like.
- On your Archive Templates, Edit the Entry Listing template
- On the Template Options, Create an Archive Mapping of type Yearly
- Choose your desired path eg. yyyy/index.html
- Specify publishing option as Static
- Hit Save and Publish
- Navigate back to your Widgets template list at Design->Widgets
- Choose which sidebar you wish to place your yearly archives by clicking it. I choose my primary sidebar since i want to replace my monthly archives into yearly archives.
- Click on the Archives Widget at the Installed Widgets List
- Place an ignore code around your monthly archive code
<mt:Ignore>
<mt:IfArchiveTypeEnabled archive_type="Monthly">
<$mt:include widget="Monthly Archives"$>
</mt:IfArchiveTypeEnabled>
</mt:Ignore> - Insert the following code right below it.
<mt:IfArchiveTypeEnabled archive_type="Yearly">
<$mt:include widget="Yearly Sidebar Archives"$>
</mt:IfArchiveTypeEnabled> - Republish your indexes and see the output at your main page.
Leave a comment