Tuesday, November 1, 2022
HomeWordPress Developmentphp - Substitute the picture of a product with its video within...

php – Substitute the picture of a product with its video within the store web page


I’m making an attempt to switch the picture of the merchandise with its video within the store web page.
I attempted this one

add_action( 'init', 'get_product_video_url' );

operate get_product_video_url() {

   $product_ids = get_posts( array(
        'post_type' => 'product',
        'numberposts' => -1,
        'post_status' => 'publish',
        'fields' => 'ids'
   ) );
   foreach ( $product_ids as $product_id ) {
    $video_url = get_post_meta( $product_id, 'video_url', true );
    
    echo '<script src="https://code.jquery.com/jquery-3.6.1.min.js"></script>';
    echo '<script src="https://code.jquery.com/ui/1.13.2/jquery-ui.min.js"></script>';
    echo "<script kind="textual content/javascript">
    jQuery(doc).prepared(operate($){
        $("<video playsinline="playsinline" autoplay="autoplay" loop="loop" muted="muted" preload="metadata"><supply src="'$video_url'" kind="video/mp4"></video>").insertAfter("ul.merchandise li.product .product-thumbnail .woocommerce-loop-product__link"); });
    </script>";

   }
 }

however I can not get it to work.

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments