Generate an array of post IDs in current query Returns an array of post IDs in the main query. Useful when doing a secondary query and you don’t want to have duplicate posts. From: http://www.billerickson.net/code/generate-an-array-of-post-ids-in-current-query/
<?php
global $wp_query;
$posts = wp_list_pluck( $wp_query->posts, 'ID' );
?>