Use posts_where to exclude posts ids from wp_query
Instead of using posts_where it is a better idea to use pre_get_posts filter. Here is the code I end up implementing: add_filter( ‘pre_get_posts’, ‘hide_unwanted_posts_filter’ ); function hide_unwanted_posts_filter( $query ) { global $current_user; get_currentuserinfo(); $user_id = $current_user->ID; $key = ‘unwanted_posts’; $unwanted_posts = get_user_meta($user_id,$key,true); if(is_user_logged_in() && !empty($unwanted_posts) && !$query->is_admin) { $query->set(‘post__not_in’, $unwanted_posts ); // id of page … Read more