I'm trying to apply a php code snippet to my wordpress page to enable Jetpack to limit its related posts to no later than 2017-01-01. However, when I add this code via Snippets - with Jetpack enabled to show thumbnails - Jetpack doesn't work. Is my code incorrect or is there some magic trick for this?
// related posts - don't show posts earlier than January 1 2017
function jetpackme_exclude_related_post($exclude_post_ids, $post_id ) {
$args = array(
'date_query' => array(
'before' => 2017-01-01,
'inclusive' => true,
),
'posts_per_page' => '99999',
'fields' => 'ids'
);
$query = new WP_Query($args);
if ($query->have_posts()):
foreach($query->posts as $id ):
$exclude_post_ids[] = $id;
endforeach;
endif;
return $exclude_post_ids;
}
add_filter( 'jetpack_relatedposts_filter_exclude_post_ids',
'jetpackme_exclude_related_post', 20, 2 );