Thoughts, Ideas, Tutorials & What we had for Lunch

How to show the PREVIOUS ten articles in WordPress and Expression Engine

Tweet this

What’s the point of a recent posts list? That’s the question I asked in a post a few days ago. If your blog page lists 10 posts, why list those same 10 post titles on the sidebar?!? (this is a pet peeve, can you tell?)

Now, let’s say you’re listing 10 posts on your blog. If your recent posts listed the next 10 posts – ie the next batch of posts that had “fallen off” the home page, you’d be listing something of value.

Here’s a very brief overview of how to make your recent posts list more useful. As an aside, it’s also an insight into the difference between WordPress and Expression Engine

If you’re using Expression Engine, it’s very easy. In the Templates section of the control panel, find the template for your sidebar (or wherever the recent posts list lives). Look for the bit of code that says something like

exp:weblog:entries weblog="news" orderby="date" limit="10"

All you need to do is add offset=”10” (within the curly brackets) to the code above, and you’re set.

If you’re using WordPress, it’s a bit trickier. Look in sidebar.php (or footer.php, if your recent posts list is in the footer) for the bit of code for your list. How that code looks may differ according to who coded the template you’re using. Once you locate the code, replace it with the following:

?php $my_query = new WP_Query(’showposts=10&offset=20’);

while ($my_query->have_posts()) : $my_query->the_post();

$do_not_duplicate = $post->ID;?

This little example highlights one of the core differences between Expression Engine and WordPress. In WP, you’re working directly with the guts of the system. It’s messy, but also very powerful. Expression Engine by contrast, hides a lot of the background code that goes into making a site work. By no means is it less powerful though – you can use raw php in your EE templates.

Hopefully this gives you a bit of insight into changing your recent articles list from duplicating the info already on the page to something more useful. If you have specific questions about how to accomplish this using your blogging platform, leave a question in the comments, and I’ll try to get the answer for you.