Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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.
global $wp_query;
$posts = wp_list_pluck( $wp_query->posts, 'ID' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment