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

echo $query->post->ID;

endwhile;

Advertisements