Hook to get the query result after listing posts

Hook to get the query result after listing posts

Use the loop_end hook – it passes the WP_Query by reference.

add_action( 'loop_end', 'wpse_263822_loop_end', 10, 1 );
function wpse_263822_loop_end( $query ) {
  //* Make sure we're in the loop
  if( ! in_the_loop() ) {
    return;
  }
  //* Do something useful with the WP_Query
  print_r( $query->posts );
}