Title: API REST
Last modified: January 29, 2021

---

# API REST

 *  Resolved [enriqued55](https://wordpress.org/support/users/enriqued55/)
 * (@enriqued55)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/api-rest-7/)
 * The gallery appears in the edit page but I can’t see the gallery (url,ids,images)
   in the api, but I can see all the other acf data.
    -  This topic was modified 5 years, 4 months ago by [enriqued55](https://wordpress.org/support/users/enriqued55/).
    -  This topic was modified 5 years, 4 months ago by [enriqued55](https://wordpress.org/support/users/enriqued55/).

Viewing 2 replies - 1 through 2 (of 2 total)

 *  Thread Starter [enriqued55](https://wordpress.org/support/users/enriqued55/)
 * (@enriqued55)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/api-rest-7/#post-13985958)
 * I solved it:
 * <?php
    $post_type = “evento”; function my_rest_prepare_post($data, $post, $request){
   $_data = $data->data;
 *  $_data[‘acf_photo_gallery’] = acf_photo_gallery(‘galeria_detalle’, $post->ID);
   
   $data->data = $_data; return $data; } add_filter(“rest_prepare_{$post_type}”,‘
   my_rest_prepare_post’, 10, 3);
 * ?>
 *  [lawrencewitt](https://wordpress.org/support/users/lawrencewitt/)
 * (@lawrencewitt)
 * [5 years ago](https://wordpress.org/support/topic/api-rest-7/#post-14491104)
 * Thank you for resolving this, I found your answer very useful. However, the syntax
   you used threw errors when I tried to paste it directly into my site – specifically
   the quote marks `“` and `‘`, it appears they are not valid for PHP. You should
   use `"` and `'` instead.
 * Here is a correctly formatted version:
 *     ```
       $post_type = "evento";
   
       function my_rest_prepare_post($data, $post, $request) {
         $_data = $data->data;
   
         $_data['acf_photo_gallery'] = acf_photo_gallery('galeria_detalle', $post->ID);
         $data->data = $_data;
   
         return $data;
       }
   
       add_filter("rest_prepare_{$post_type}", 'my_rest_prepare_post', 10, 3);
       ```
   
 * Also, for anyone new to WordPress (like me), some tips on where/how to use this
   would have been great!
 * The `$post_type` variable should be the slug of your post type, and the first
   argument passed to `acf_photo_gallery` should be the name of the acf gallery 
   field you are trying to match. I eventually figured out I could install the Code
   Snippets plugin and add this as a new snippet. It now works fine.
    -  This reply was modified 5 years ago by [lawrencewitt](https://wordpress.org/support/users/lawrencewitt/).

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘API REST’ is closed to new replies.

 * ![](https://ps.w.org/navz-photo-gallery/assets/icon-128x128.png?rev=2607741)
 * [ACF Photo Gallery Field](https://wordpress.org/plugins/navz-photo-gallery/)
 * [Support Threads](https://wordpress.org/support/plugin/navz-photo-gallery/)
 * [Active Topics](https://wordpress.org/support/plugin/navz-photo-gallery/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/navz-photo-gallery/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/navz-photo-gallery/reviews/)

## Tags

 * [API REST](https://wordpress.org/support/topic-tag/api-rest/)

 * 2 replies
 * 2 participants
 * Last reply from: [lawrencewitt](https://wordpress.org/support/users/lawrencewitt/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/api-rest-7/#post-14491104)
 * Status: resolved