• Resolved Pedro

    (@petredobrescu)


    Hello,

    I’ve setup JetPack related posts and limited them to only 48 hours using this code added in functions.php (following the example in the documentation):

    function g4m_related_posts_past_2_days_only( $date_range ) {
    	$date_range = array(
    		'from' => strtotime( '-48 hours' ),
    		'to' => time(),
    	);
    	return $date_range;
    }
    add_filter( 'jetpack_relatedposts_filter_date_range', 'g4m_related_posts_past_2_days_only' );

    I’ve also tried with ‘-2 days’ and it still doesn’t work. Basically, it shows results which are far older than 2 days. Is there any limitation around this? This is a news site and it doesn’t make any sense showing news which are 2-3 weeks old.

    Thank you!
    Pedro

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Can’t restrict related posts to only 48 hours’ is closed to new replies.