admin管理员组文章数量:1122846
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..
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..
Share Improve this question asked May 18, 2020 at 8:20 Divya MohanDivya Mohan 12 bronze badges 2- Is this a custom post type with a video_url field? You'd need to register the field for the REST API. Or a regular post with a YouTube URL in it that gets turned into a player with oEmbeded? – Rup Commented May 18, 2020 at 8:25
- its a custom post video – Divya Mohan Commented May 18, 2020 at 9:54
1 Answer
Reset to default 0You 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.
本文标签: Need wp rest api for featured video post
版权声明:本文标题:Need wp rest api for featured video post 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736292352a1928916.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论