/**
  * WP_Query Loop that has been triggered from the endpoint.
  *
  * @return array An array with the data associated with the request.
  */
 protected function loop()
 {
     $data = [];
     $meta = [];
     $this->args = apply_filters(Collection\Filter::COLLECTION_ARGS, $this->args);
     $this->query = new \WP_Query($this->args);
     while ($this->query->have_posts()) {
         $this->query->the_post();
         $data[] = $this->format_item($this->query->post);
         if (empty($meta)) {
             // Take the metadata from the first post.
             $meta = \Lean\Utils\Meta\Collection::get_all_collection_meta($this->query->post);
         }
     }
     wp_reset_postdata();
     $response = ['data' => $data, 'meta' => $meta, 'pagination' => $this->get_pagination($this->query->found_posts, $this->query->max_num_pages)];
     return apply_filters(Collection\Filter::COLLECTION_DATA, $response, $this->args);
 }