apply_filters ( 'jetpack_relatedposts_filter_exclude_post_ids', array $args[’exclude_post_ids’], string $post_id )

Filter the Post IDs excluded from appearing in Related Posts.

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

View in GitHub

Parameters

$args[’exclude_post_ids’]

(array) Array of Post IDs.

$post_id

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


Changelog

Since: Jetpack 2.9.0


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

Have a note to contribute?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s