« Date Formats | Main | Creating an Additional Weblog »

Previous Entries and Lastn

Updated February 22, 2007

The default main index page of a Movable Type weblog displays the last 10 entries made. You can change this number by entering a different number in the weblog's settings. Settings > General > Default Weblog Display Settings > Entries to Display

You can also change the default settings so that they display the last X number of days worth of entries.

Outside of the default set up, if you want to display a certain number of entries, you need to use the lastn attribute.

Changing <MTEntries> to <MTEntries lastn="7"> in the Main Index template will cause the index page to display the last 7 entries. Adding the attribute lastn="10" will cause the index page to display the last 10 entries, and so forth.

Previous Entries
Sometimes it is useful to show a list of the most recent entries that came before the entries that are displayed on your main index page. Rather than creating a super long page with 17 entries, you might want to display 7 entries and show a list of the 10 entries that came before, with links to their corresponding full entries.

To show a list of previous entries you need to employ the "offset" attribute. For example, if you wanted to show a list of the 10 entries that came before your 7 most recent entries, you would use a tag that looked like this:

<MTEntries lastn="10" offset="7">

The code that I have used on various blogs looks something like this:

<h3>Previous 10 entries...</h3>
<MTEntries lastn="10" offset="7">
<a href="<$MTEntryPermalink$>"><$MTEntryTitle$></a> <$MTEntryDate format="%b %e, %Y"$><br />

This code I've placed right after the </MTEntries> tag that is the closing tag for the MTEntries section of code that governs the main display of entries on the page.

Comments (2)

You're a God-send I love learning off your site! Thank you Thank you Thank you!


if i want to show top 3 entries which are not under any category how will this be implemented.

Post a comment

(If you haven't left a comment here before, your comment may need to be approved before will appear on the entry. Thanks for waiting.)