YouTube Playlist Bricks Query Loop

YouTube Playlist Bricks Query Loop

Updated on 16 Feb 2024

In the BricksLabs Facebook group a user asked:

I've been battling to display a YouTube Playlist in grid form on a site. The Bricks Video element does not allow for playlists.

From searching Bricks community platforms, most suggestions are to use a 3rd party plugin.

Is it at all possible to do this without a 3rd party plugin? If so; - I'd love to see a tutorial on this.

This Pro tutorial provides the steps to register a custom query type, which, when selected, enables you to use Bricks elements like Video, Heading, and Image to output the embedded video iframe, title, and thumbnail of videos of a specified YouTube playlist in a Bricks query loop.

We shall use YouTube Data API.

Step 1

Go to the Google Cloud Platform Console and get an API key for the YouTube Data API.

The general outline is that you’d first create a Project, switch to it, go to "APIs and services", click "Enable APIs and Services" button, search for youtube, click "YouTube Data API", enable it, go to Credentials, create a credential of API key type to get the API key.

Details:

  1. You need a Google Account to access the Google API Console, request an API key, and register your application.
  2. Create a project in the Google Developers Console and obtain authorization credentials so your application can submit API requests.
  3. After creating your project, make sure the YouTube Data API is one of the services that your application is registered to use:
    1. Go to the API Console and select the project that you just registered.
    2. Visit the Enabled APIs page. In the list of APIs, make sure the status is ON for the YouTube Data API v3.

Step 2

Keep your desired YT playlist's ID handy.

In this example, we shall use this playlist:

https://www.youtube.com/playlist?list=PL3VM-unCzF8ipG50KDjnzhugceoSG3RTC

so the ID is: PL3VM-unCzF8ipG50KDjnzhugceoSG3RTC

Step 3

Add the following in child theme's functions.php (w/o the opening PHP tag) or a code snippets plugin:

This is a BricksLabs Pro tutorial.

For full access login below or create your BricksLabs Pro account

Get access to all 525 Bricks code tutorials with BricksLabs Pro

Related Tutorials..

How to display a Query Loop in 3 columns in Bricks

How to display a Query Loop in 3 columns in Bricks

This tutorial provides the builder settings and CSS codes that can be pasted in order to create a 3-columns query loop container inside Bricks Builder.
Categories:
Pro
ACF Post Object Query Loop inside a Posts Query Loop in Bricks

ACF Post Object Query Loop inside a Posts Query Loop in Bricks

How to loop through a CPT and within each post, output a list of related posts.
Categories:
Pro
Displaying Gallery of SureCart Product Images with Bricks’ Query Loop

Displaying Gallery of SureCart Product Images with Bricks’ Query Loop

Custom query loop for looping through SureCart product images.
Categories:
Tags:
Bricks Templates Query Loop

Bricks Templates Query Loop

How display Bricks Templates with saved screenshots in a query loop.
Categories:
Pro
Query Loop in Bricks

Query Loop in Bricks

This Pro tutorial walks you through the steps to use the Query Loop feature in Bricks to display a responsive grid of posts using CSS…
Categories:
Pro
Top-level Pages and Children Bricks Query Loop

Top-level Pages and Children Bricks Query Loop

This Pro tutorial for Bricks users can be considered Part 2 or a variation of the earlier Bricks Query Loop for Top-level Parent Pages with…
Categories:
Pro
Posts Grouped by Post Dates in Bricks

Posts Grouped by Post Dates in Bricks

Setting up query loops for “Post Dates” with an the inner loop displaying all posts published on that day.
Categories: