woocommerce offtopic – get embedded video url of the products in functions.php

Question

Any ideas on how to make a function that will pull all the embedded video url of woocommerce products?

I tried this one but it returns all video attachments in the site.

add_action( 'init', 'echo_product_video_url' );
function echo_product_video_url() {
$all_urls = get_posts( array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => 'inherit',
'post_mime_type' => 'video/mp4'

) );
foreach ( $all_urls as $url ) {
echo '<pre>';
print_r($url);
echo '</pre>';
}
}

Any help would be much appreciated!

0
dev-one 1 month 2022-10-31T08:16:29-05:00 0 Answers 0 views 0

Leave an answer

Browse
Browse