Changing the $post assignment to use the WP_Query objects post item.