apply_filters ( 'jetpack_relatedposts_filter_date_range', array $args[’date_range’], string $post_id )

Filter the date range used to search Related Posts.

Source file: modules/related-posts/jetpack-related-posts.php

View in GitHub



(array) Array of a month interval where we search Related Posts.


(string) Post ID of the post for which we are retrieving Related Posts.


Since: Jetpack 2.8.0


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

Have a question?

Comments are closed for this article, but we're still here to help! Visit the support forum and we'll be happy to answer any questions.

View support forum