Return most recent post by date range

Open functions.php from the template file and add this function:

function show_month_posts($where) {
global $wpdb;

$how_long = 60; //60 days

//if( !is_single() && !is_page() )
if( is_home() )

$where .= " AND $wpdb->posts.post_date >= ADDDATE(CURRENT_DATE(), - $how_long)";

return $where;
}
if (is_home ) add_filter('posts_where', 'show_month_posts');

Tags: ,

This entry was posted on Thursday, May 8th, 2008 at 10:35 pm and is filed under How-To, WordPress. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

One Response to “Return most recent post by date range”

Return most recent post by date range - Hariadi.Org May 8th, 2008 at 10:39 pm

[...] UPDATED: This trick not work with paging. Go to another trick [...]

Leave a Reply