Fix Mixed-Mode YouTube Embeds in WordPress

Are you attempting to embed YouTube videos in a secure (https) WordPress site?  Well, browsers should be blocking that content since the videos are not coming in over a secure channel.

A consequence is that some YouTube videos won’t display, and an error won’t be displayed–which is annoying.

Here is a brief snippet that can be added to your functions.php file to fix the problem once and for all.

The line beginning with “$search” specifies that we are searching for non-secure links to YouTube, and the return line combs through the post, and fixes the links so the embeds display properly.  It’s a simple fix, based on WordPress’ powerful filter hook system.

Neat Ad

I’m a huge fan of Lorde’s song “Royals.” This ad features it wonderfully.