Koen's blog Profile Photo

Koen's blog

Ik typ. Ik typ voor mijn Sien, Arwen, Mila en Nienke.

Recent posts wp-hack

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.