Show custom fields in the API rest
-
Hello everyone!
I have installed the plugin advanced custom fields, and I am showing the fields in the API rest of the wordpress, using this code in the file function.php of the theme:$post_type = "post"; function my_rest_prepare_post($data, $post, $request) { $_data = $data->data; $fields = get_fields($post->ID); foreach ($fields as $key => $value){ $_data[$key] = get_field($key, $post->ID); } $data->data = $_data; return $data; } add_filter("rest_prepare_{$post_type}", 'my_rest_prepare_post', 10, 3);
Then add the plugin ACF Photo Gallery Field so you can create gallery and display them in the rest API as well, but this does not happen.
How should I do to show the image galleries that are part of the custom fields?The fields that I created with the plugin are:
slogan
description
plans
engineType
seats
performance
price
cilindrada
video
iconAnd so they look at the API rest https://admin.prototipowp.tk/wp-json/wp/v2/posts?categories=2
The page I need help with: [log in to see the link]
- The topic ‘Show custom fields in the API rest’ is closed to new replies.