Changing the $post assignment to use the WP_Query posts array.