How to display all oembed fields on custom page with ACF

517 views Asked by At

I should create a page where you can view all videos (oembed field) of a specific custom post type.

Example: Custom Post Type = Project

Inside Project there are 4 articles and inside each of them 4 videos are uploaded.

So my question is: how can I structure my feature so that it allows me to extract the videos of all the articles and show them in a single page?

1

There are 1 answers

0
Danil Rusakov On BEST ANSWER

Try this code, but change key of your custom video field

$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();