filter

jetpack_relatedposts_filter_exclude_post_ids

Filter the Post IDs excluded from appearing in Related Posts.

Parameters

$args
array

['exclude_post_ids'] Array of Post IDs.

$post_id
string

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

Changelog

How to use this hook

See “How to use actions and filters to customize Jetpack”.

Notes

In the following example, 1037 and 1038 are the IDs of the posts we want to exclude:
function jetpackme_exclude_related_post( $exclude_post_ids, $post_id ) {
    // $post_id is the post we are currently getting related posts for
    $exclude_post_ids[] = 1037; // Exclude post_id 1037
    $exclude_post_ids[] = 1038; // Also exclude post_id 1038
    return $exclude_post_ids;
}
add_filter( 'jetpack_relatedposts_filter_exclude_post_ids', 'jetpackme_exclude_related_post', 20, 2 );