Theme Functions
You may want to customize your theme to better display your video posts in lists and on single pages. This plugin has a number of functions built-in that might help you along the way.
Before you can use any theme functions you have to place the following code at the top any PHP files using the theme functions:
<?php use ternplugin\youtube_video as youtube_video; ?>
This code must be the very first line of code in the file!!!
Here is a list of function you can use in post lists and in post templates:
The Video Function
You may want to display videos in a specific location. To display a video use the following code:
<?php
$video = new youtube_video();
echo $video->video();
?>
This code will display a video for whatever post is active.
The Video URL Function
You may want to get the URL of the video for the active post.
<?php
$video = new youtube_video();
echo $video->video_url();
?>
The Video Watch URL Function
If you’d like to print the video’s watch URL use the following:
<?php
$video = new youtube_video();
echo $video->video_watch_url();
?>
The Video Thumbnail Function
If you want to get the URL for the active post’s YouTube® video’s thumbnail you can use the following function.
<?php
$video = new youtube_video();
$thumbnail = $video->thumb('default');
?>
There are a number of sizes you can retrieve using this function. They are as follow:
- default
- medium
- high
- standard
- maxres
The Video YouTube® Author URL Function
If you’d like to print the video’s author’s URL use the following:
<?php
$video = new youtube_video();
echo $video->author_url();
?>