Subscribe to RSS Feed
Twitter
HIRE ME! home  archives  about  blogroll

Recent posts wp-hack

19 May 2004

My index page first showed the five recent posts. I just changed that to show the most recent 5 days. Since I use the recent posts hack, there was a small problem. It showed the 10 most recent posts skipping the first 5 (because they used to be on the main page).

A quick look at the hack and MySQL date functions made me come up with this:

basically replace this line:
$request = "SELECT ID, post_title FROM $tableposts WHERE post_status = 'publish' ";

by this line:
$request = "SELECT ID, post_title FROM $tableposts WHERE post_status = 'publish' AND DATE_SUB(CURDATE(),INTERVAL 4 DAY) > post_date ";

To make it a bit cleaner, here’s the modified function. It takes an extra parameter “skip_days” which specifies the number of days to skip.

blog comments powered by Disqus