This seems to work:
/**
* Adds a time constraint condition so WPP returns only posts that
* are up to 6 months old.
*
* @param string $where Original WHERE clause
* @param array $options Plugin settings
* @return string The filtered WHERE clause
*/
function wpp_limit_post_age( $where, $options ){
if ( ! is_admin() ) {
$where .= " AND p.post_date > DATE_SUB(NOW(), INTERVAL 6 MONTH) ";
return $where;
}
return $where;
}
add_filter( 'wpp_query_where', 'wpp_limit_post_age', 10, 2 );
Basically, we’re using an undocumented filter hook to modify the query WPP uses to retrieve posts from your database.
Since you want to display posts that are no more than a year old, you need to change INTERVAL 6 MONTH
to INTERVAL 12 MONTH
(or INTERVAL 1 YEAR
).
Note that said filter hook has been left undocumented for a very good reason: I may make changes to the original query (as I just did) which in turn might break your customization, breaking the query and thus the widget completely in the process. This mod, however, should be safe. I honestly don’t think you need to worry about it.
Also, for this mod to work you’ll want to keep the “Display only posts published within the selected Time Range” option unchecked.
And, in case you’re wondering, you need to add this code snippet to your theme’s functions.php file.