Follow the tutorial below on how to display YouTube video counts in WordPress on any page, post, or custom post type. You will end up with a shortcode that you can easily use wherever you want. This tutorial uses the latest YouTube Data API (v3) as v2 is now deprecated. Step 1 First you are going to need an API key from Google. So go to Google Developers Console and login with your Google account. Step 2 Create the new project (name does not matter). Step 3 Click into your new project from the dropdown. In the sidebar on the left, expand APIs & auth. Next, click APIs. In the list of APIs go to YouTube Data API (v3) and make sure that it’s enabled (Enable API). Step 4 In the same sidebar click Credentials. Then click on “Add credentials” and choose “API key.” Step 5 Then click on “Browser Key.” Step 6 Under referrers simply leave it blank and click on “Create.” Step 7 On the next screen you will see a popup with your new API key. Copy this as you will need it later on. Step 8 Now we need to create your shortcode in WordPress. So click into “Appearance” and then into “Editor.” Step 9 Then click into your functions.php file. Step 10 Now add the code below to the bottom of your functions.php
Share This