Q:

Exclude posts from widget while post is showing on home, single and categories

Im using this widget.
but im trying to figure out how to get it to not display any posts that are currently being
displayed on the home page, single post and categories.
Another user raised the same question here
Which provided the following solution:
add_filter( 'rpwe_default_query_arguments', 'rpwe_exclude_current_post' );
function rpwe_exclude_current_post( $args ) {
if( is_singular() && !isset( $args['post__in'] ) )
$args['post__not_in'] = array( get_the_ID() );
return $args;
}

It worked but for single posts only not for posts in home page or categories.

A:

Specific support for third party plugins are off topic, but your question can be answered in a general scope. get_the_ID() will not work for this specific issue, what you need is an array of post ID's that is currently being displayed on the page you are viewing.
The current array of posts that is being displayed on any given page is stored in the $posts property of the main query or any custom instance of WP_Query. It is from here that you would want to extract all the post ID's from to pass to $args['post__not_in'] in your code in question.
You can try the following in your code above
global $wp_query;
$post_ids = wp_list_pluck( $wp_query->posts, 'ID' );

Then you can feed $post_ids to $args['post__not_in']
$args['post__not_in'] = $post_ids;

You just need to pass the correct conditionals to target your specific pages

