Forked from Spirecool/Show Video Instead of Product Images
Created
July 28, 2022 18:07
-
-
Save racmanuel/993e175df307cdfe648db5b677fd4bf5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( 'woocommerce_before_single_product', 'bbloomer_show_video_not_image' ); | |
function bbloomer_show_video_not_image() { | |
// Do this for product ID = 282 only | |
if ( is_single( '282' ) ) { | |
remove_action( 'woocommerce_before_single_product_summary', 'woocommerce_show_product_images', 20 ); | |
remove_action( 'woocommerce_product_thumbnails', 'woocommerce_show_product_thumbnails', 20 ); | |
add_action( 'woocommerce_before_single_product_summary', 'bbloomer_show_product_video', 20 ); | |
} | |
} | |
function bbloomer_show_product_video() { | |
echo '<div class="woocommerce-product-gallery">'; | |
// get video embed HTML from YouTube | |
echo '<iframe width="560" height="315" src="https://www.youtube.com/embed/JHN7viKRxbQ?rel=0&showinfo=0" frameborder="0" allowfullscreen></iframe>'; | |
echo '</div>'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment