I was recently working on a client’s website and wanted to automatically feature the latest video from their YouTube channel and embed it on a page. Fortunately YouTube provides RSS feeds for channels, and WordPress has the ability to parse RSS feeds by calling the fetch_rss function, so I wrote this little script to embed the latest video.
Just set the username of the channel you’d like to fetch videos from in the third line of code by replacing “CHANNEL-USERNAME”. You can also increase the amount of videos you’d like to display by increasing $maxitems.
(No, Stephen Fry isn’t the client!)