[ad_1]
Hello, can anyone see why this would not be working in a block? When I run this code in an ad inserter block, the page displays very strange and I get a critical error message. I’m trying to open random videos in wp lightbox after clicking and image. No other info.
<?php
function displayRandomVideoWithBanner() {
// Define video URLs and banner image URL
$video_urls = array(
"https://www.youtube.com/watch?v=VideoId1",
"https://www.youtube.com/watch?v=VideoId2",
"https://www.youtube.com/watch?v=VideoId3"
);
$banner_image_url = "https://website.com/wp-content/uploads/2023/07/banner-image.png";
// Shuffle the video URLs
shuffle($video_urls);
// Select the first video URL
$random_video_url = array_shift($video_urls);
// Check if a valid video URL is available
if ($random_video_url) {
// Create HTML output
echo "<a href="https://projectdmc.org/support/topic/php-not-working-in-block/$random_video_url" rel="wp-video-lightbox"><img src="$banner_image_url" alt="alt text"></a>";
} else {
// If no valid video URL is available
echo "Error: No valid videos found.";
}
}
// Call to display the video and banner
displayRandomVideoWithBanner();
?>I cant just use a simple [ADINSERTER ROTATE] because when I do, it doesn’t open the video in the wp lightbox, it just links directly to youtube.
Thank you
