CodeHQ

Exclude current post from WordPress query

Get the current page ID and use that in the WordPress query to exclude that post from displaying.

<?php $currentID = get_the_ID();?>

<?php $args = array(
	'post_type' => 'post',
	'post__not_in' => array($currentID)
);

$query = new WP_Query($args);

 $i = 1;

while ( $query->have_posts() ) : $query-> the_post(); ?>