WordPress 5.3.x YouTube oEmbed is not working
We followed Brian Fegter's answer to display YouTube videos using WordPress' oEmbed feature:
// Public video.
$video_url = 'https://www.youtube.com/watch?v=1lODe0i7dNw';
require_once(ABSPATH . 'wp-includes/class-wp-oembed.php');
$oembed = new WP_oEmbed;
// Auto-detect the video provider with the following
$provider = $oembed-discover($video_url);
$video = $oembed-fetch($provider, $video_url);
echo $video-html;
The code worked earlier. But right now it's not working. We're using WordPress 5.3.2. We tried updating WordPress to 5.3.6, but no luck.
The main issue is: $oEmbed-discover()
cannot detect any provider and returning false
. :(
You can see the issue live at this link. (For some time, we're showing some of the debug information, if you need them)