Guest User

Untitled

a guest
Apr 19th, 2018
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. /**
  2. * Retrieve restaurants.
  3. */
  4. public function get_items( $request ) {
  5. $args = array(
  6. 'post_type' => $this->post_type,
  7. 'posts_per_page' => $request['per_page'],
  8. 'page' => $request['page'],
  9. );
  10.  
  11. $restaurants = get_posts( $args );
  12. $data = array();
  13.  
  14. if ( $restaurants ) {
  15. foreach ( $restaurants as $restaurant ) :
  16. $itemdata = $this->prepare_item_for_response( $restaurant, $request );
  17. $data[] = $this->prepare_response_for_collection( $itemdata );
  18. endforeach;
  19. }
  20.  
  21. $data = rest_ensure_response( $data );
  22. return $data;
  23. }
Add Comment
Please, Sign In to add comment