Filter the date range used to search Related Posts.
Parameters
- $args
array ['date_range'] Array of a month interval where we search Related Posts.
- $post_id
string Post ID of the post for which we are retrieving Related Posts.
Changelog
- Introduced in Jetpack 2.8.0
How to use this hook
Notes
In the example below, we use the filter to only return posts from the past 6 months:
function jetpackme_related_posts_past_halfyear_only( $date_range ) {
$date_range = array(
'from' => strtotime( '-6 months' ),
'to' => time(),
);
return $date_range;
}
add_filter( 'jetpack_relatedposts_filter_date_range', 'jetpackme_related_posts_past_halfyear_only' );