wordpress loop over posts but exclude current post

Solutions on MaxInterview for wordpress loop over posts but exclude current post by the best coders in the world

showing results for - "wordpress loop over posts but exclude current post"
Syrine
20 Nov 2017
1$args = array(
2    'numberposts' => 5,
3    'offset' => 0,
4    'category' => 7,
5    'post__not_in' => array( $post->ID )
6);
7$myposts2 = get_posts($args);