Skip to content


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');

Posted in How-To, WordPress.

Tagged with , .


One Response

Stay in touch with the conversation, subscribe to the RSS feed for comments on this post.

Continuing the Discussion

  1. Return most recent post by date range - Hariadi.Org linked to this post on May 8, 2008

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



Some HTML is OK

or, reply to this post via trackback.