Using YouTube API to show videos automatically on WordPress site

“A picture is worth a thousand words”

Moving pictures are even better! Thus, a while ago a friend asked me to help her show the most recent three videos from her YouTube channel on her website. Of course, I could have told her to copy and paste the YouTube URL into the editor, as WordPress provides 30+ embeds put of the box. This solution, however, would require that every time she uploads a video to YouTube, she would then have to manually add the video to her WordPress site.

Instead, I decided using the YouTube API and suggested to pull the videos automatically from her channel and playlist. This avoids manual effort and ensures that the latest videos are always visible on the site. Luckily implementing the YouTube API with WordPress is as easy as pie. I created the following code to show the latest three videos from her YouTube channel on her site:

Of course, requirements change over time. In the meantime, she created 30+ videos and wants to handpick three videos that should be shown on the homepage.

I suggested to create a separate playlist for the homepage videos and show the videos of this playlist instead of the videos of her channel. To reflect the new requirements I changed the code as follows:

Also, she created a private YouTube playlist, to ensure that this playlist will not show within her YouTube playlists, but the videos can be accessed publicly.

Resources

 

Using WP-CLI on VVV without SSH

For years I’ve been using MAMP PRO. After blowing up my database recently, I decided to finally switch over to VVV. Luckily I got a fantastic introduction from Konstantin Obenland during the Contributor Day at the WordCamp Bangkok 2018.

After having touched VVV for almost two weeks, I decided to get my hands dirty this weekend and start migrating my projects over to VVV. While creating the projects (and their virtual hosts) was rather easy, I got stuck with using WP-CLI on VVV. After searching for a while, I stumbled upon a post on Github from Joe Hoyle.

Joe suggested updating the wp-config.php or to use bash functionality to use WP-CLI within VVV without SSH. I decided to follow the first approach and changed the MySQL settings within my wp-config.php from

to

Please note that changing the DB_HOST only is not enough. Both, the DB_HOST, the DB_USER and the DB_PASSWORD have been changed so that the WP-CLI can be used within VVV without SSH.

Quality vs. quantity of installed plugins

In the previous month I’ve talked to countless people about WordPress. One question keeps coming back over and over again: How many plugins can I install without facing negative affects? There’s only one answer to that question: It depends on the plugins.

Continue reading Quality vs. quantity of installed plugins

Travel back in time

Yesterday Devin and I proceeded our journey and travelled from Amsterdam to Enkhuizen to visit Arno on his ship, the Broedertrouw. The Broedertrouw is a 2 mast tall sail ship, 36 meter long, built in 1880 and birth place for my addiction in knot tying. As expected the weather was cold, windy and rainy. After a great discussion and fantastic traditional Dutch food we went to bed.

Continue reading Travel back in time

Let the journey begin

A few weeks ago a friend asked me if I ever thought about working as Happiness Engineer at Automattic. My immediate reply was “I would love to, but I’m not good enough yet.”. However, he convinced me to give it a try. Now, a few weeks later, I’ve successfully passed my first and second assignment as well as my first and second interview. And … drum roll … Automattic offered me a trial position as Happiness Engineer starting on July 3, 2017.

Continue reading Let the journey begin