Skip to content
Public Ticket #16824

REST API

Conversation thread

PenciDesign Supporter replied

Staff Reply

Hi,

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.

waerp started the conversation

Conversation Start

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

Want to join this conversation or access attachments? Sign in first.