Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/xpath/2.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
Post 如何使用ACF在自定义页面上显示所有oembed字段_Post_Video_Types_Advanced Custom Fields_Oembed - Fatal编程技术网

Post 如何使用ACF在自定义页面上显示所有oembed字段

Post 如何使用ACF在自定义页面上显示所有oembed字段,post,video,types,advanced-custom-fields,oembed,Post,Video,Types,Advanced Custom Fields,Oembed,我应该创建一个页面,您可以在其中查看特定自定义帖子类型的所有视频(oembed字段) 示例: 自定义帖子类型=项目 项目内部有4篇文章,其中每一篇都上传了4个视频 因此,我的问题是:我如何构造我的功能,使其允许我提取所有文章的视频并在一个页面中显示它们?尝试此代码,但更改自定义视频字段的键 $args = [ 'post_type' => 'project', // your custom post type 'post_status' => 'publish',

我应该创建一个页面,您可以在其中查看特定自定义帖子类型的所有视频(oembed字段)

示例: 自定义帖子类型=项目

项目内部有4篇文章,其中每一篇都上传了4个视频


因此,我的问题是:我如何构造我的功能,使其允许我提取所有文章的视频并在一个页面中显示它们?

尝试此代码,但更改自定义视频字段的键

$args = [  
    'post_type' => 'project', // your custom post type
    'post_status' => 'publish', 
];

$loop = new WP_Query( $args ); 
    
while ( $loop->have_posts() ) { $loop->the_post(); 
    $video = get_field('video', get_the_ID()); // check custom field key
    print $video;  
}

wp_reset_postdata();

@丹尼尔鲁萨科夫完美,很管用!如果我想包含多个oembed字段,该怎么办?我有embed_1、embed_2和embed_3,我希望我能把它们都挂到这个函数上