If you’re like the thousands of other bloggers out there, when you first started your blog, you went to the theme viewer or did a google search for free WordPress themes and found yourself something that you liked. Personally, I’m not a fan of themes that display the seemingly endless list of full articles right there on the homepage. I’d much rather see a couple of feature stories, and a list of either older stories, or a list of categories that I can browse through. But alas, even the free themes I’ve released have had the endless, reverse-chronological list of stories with full text and a “previous – next” link at the bottom.
And this is the case for most of the free themes out there.
What’s even funnier is the fact that some bloggers/theme designers put a list in a sidebar called “recent stories/articles”.
What?! You mean that not only do I get the long list of stories on the homepage, but I’m also getting another list in the sidebar with the exact same list? Seems like a waste of real estate, huh?
But it doesn’t have to be. By implementing this simple trick, you can change the sidebar information to display only a list of stories that are older than the stories on the homepage. Here’s how…
The Prep
First thing to do is figure out how many stories are being displayed on your homepage. Go to the WordPress dashboard and click on Options – Writing and find the section that says “Blog Pages” and check to see the number in the box that says “Show at most X posts”.
The Code
Now, find the section in your sidebar.php file that displays the recent articles. The template tag will look something like this:
<?php get_posts(‘numberposts=10’); ?>
This will output a list of your most recent 10 posts. In order to change this list to the most recent posts NOT on the homepage, we will need to offset this list. Remember the number of stories set to display on your homepage? Let’s say that number is 15. All you need to do is add the “offset” qualifier inside the parenthesis to get the list offset. It should look like this now:
<?php get_posts(‘numberposts=10&offset=15’); ?>
But what about when we leave the homepage?
Good question. If we’re not on the homepage, there’s no reason to offset the list. In fact, if someone comes to your site from an incoming link or google search, you WANT them to be exposed to your most recent posts. So, what we’ll do is use the is_home() conditional tag to only offset when we’re on the homepage. Everybody has their own opinion how how to write php conditions, but here’s what I would do:
<?php
if (is_home()) {
get_posts(‘numberposts=10&offset=15’);
}
else {
get_posts(‘numberposts=10’);
}
?>
Related Stories from The Blog Herald
Now, every time you’re on the homepage, your list is offset, and if you’re on any other page, the list displays the latest stories from your blog, not offset.
Simple huh?
Neuroscientist reveals a new way to manifest more financial abundance
Breakthrough Columbia study confirms the brain region is 250 million years old, the size of a walnut and accessible inside your brain right now.