Need wp rest api for featured video post

hi i very new to rest api...I'm using WP REST API V2 in my project. After sending Get request to get posts, I don't see fields with the source of my audio/video wordpress posts (youtube or soundcloud sources)

im trying use many api like wp-json/wp/v2/media /wp-json/wp/v2/posts?_embed wp-json/wp/v2/posts/?video_url

i dont know how to fix this..pls anyone help me to fix this..

i can able to get only featured image for tat video post..could not able to play video..

Topic rest-api Wordpress

Category Web


You have a custom post type called 'video' with a video_url field. You need to call register_post_meta in the rest_api_init hook to get the API to return this field, e.g.

function register_post_meta_video_video_url( $wp_rest_server ) {
    register_post_meta( 'video', 'video_url', array(
        'type'         => 'string',
        'description'  => 'Featured video URL',
        'single'       => true,
        'show_in_rest' => true,
    ) );
};
add_action( 'rest_api_init', 'register_post_meta_video_video_url', 10, 1 );

See REST API Modifying Responses.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.