Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/json/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Json 如何获取音频/视频源WP REST API字段?_Json_Wordpress_Rest_Html Parsing_Wordpress Rest Api - Fatal编程技术网

Json 如何获取音频/视频源WP REST API字段?

Json 如何获取音频/视频源WP REST API字段?,json,wordpress,rest,html-parsing,wordpress-rest-api,Json,Wordpress,Rest,Html Parsing,Wordpress Rest Api,我正在我的项目中使用WP-restapiv2。在发送Get请求以获取帖子后,我看不到包含我的音频/视频wordpress帖子源的字段(youtube或soundcloud源) 我想知道如何在我的请求结果中包含源字段(音频和视频帖子)。如果我的帖子是音频或视频帖子: 这些帖子的源字段可以设置为soundcloud或youtube曲目url: 我需要在get请求的结果中获取这些源。我有一个想法,它应该看起来类似于获取缩略图url设置一个函数来获取functions.php文件中的一个字段,但我

我正在我的项目中使用WP-restapiv2。在发送Get请求以获取帖子后,我看不到包含我的音频/视频wordpress帖子源的字段(youtube或soundcloud源)

我想知道如何在我的请求结果中包含源字段(音频和视频帖子)。如果我的帖子是音频或视频帖子:

这些帖子的源字段可以设置为soundcloud或youtube曲目url:

我需要在get请求的结果中获取这些源。我有一个想法,它应该看起来类似于获取缩略图url设置一个函数来获取functions.php文件中的一个字段,但我不知道如何设置它,以及应该使用哪个函数来获取音频和视频帖子的源url

在functions.php文件中获取缩略图url函数的附带示例:

add_action( 'rest_api_init', 'ccw_insert_thumbnail_url' );
                function ccw_insert_thumbnail_url() {
                    register_rest_field( 'post',
                        'ccw_thumbnail',
                        array(
                            'get_callback'    => 'ccw_get_thumbnail_url',
                            'update_callback' => null,
                            'schema'          => null,
                        )
                    );
                }

            function ccw_get_thumbnail_url($post){
                if(has_post_thumbnail($post['id'])){
                    $imgArray = wp_get_attachment_image_src( get_post_thumbnail_id( $post['id'] ), 'thumbnail' );
                    $imgURL = $imgArray[0];
                    return $imgURL;
                }else{
                    return false;   
                }
            }
可能的重复可能的重复