How do I change the order of my archive links?
Note: This article is for classic templates. If your blog is using Layouts, this feature is supported as an option by the archive page element. (Select the "flat list" option and uncheck "show oldest posts first.")
To do this on your blog, you'll just replace the default archive code with the following:
var archives = new Array();
archives[archives.length] = new Array('<$BlogArchiveURL$>', '<$BlogArchiveName$>');
for (var i=archives.length-1;i>=0;i--)
document.write('<li><a href=\"' + archives[i] + '\">' + archives[i] + '</a></li>');
What's happening here is that the
for loop, we cycle through them all backwards, and this time we go ahead and print them out, in their new order. You can copy this code directly into your template, without having to make any modifications.
- This code prints out the links as an unordered list. If you want to use a different format, simply replace the
<li>tags with the appropriate HTML for your design.