Comments 1waerp started the conversationMay 20, 2021 at 9:57amHi,is it possible to extend the existing WP REST API with the fields from recipes? This would be awesome. I am trying to create an app for my recipe homepage and just want to show there also recipes.Best regards 2,616PenciDesign repliedMay 20, 2021 at 11:12amHi,Please install the Code Snippet plugin, then add the following code: function waerp_filter_post_json( $data, $post, $context ) { $postmetas = get_post_meta($post->ID); foreach($postmetas as $meta_key=>$meta_value) { $data->data[$meta_key] = $meta_value[0]; } return $data;}add_filter( 'rest_prepare_post', 'waerp_filter_post_json', 10, 3 );This code will return all custom meta keys of post type name: post in REST API result.Best Regards,PenciDesign.1 Like Sign in to reply ...
Hi,
is it possible to extend the existing WP REST API with the fields from recipes? This would be awesome.
I am trying to create an app for my recipe homepage and just want to show there also recipes.
Best regards
Hi,
Please install the Code Snippet plugin, then add the following code:
This code will return all custom meta keys of post type name: post in REST API result.
Best Regards,
PenciDesign.