Last active
February 7, 2019 12:43
-
-
Save billerickson/00ae412b056590bbb5d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$videos = get_post_meta( get_the_ID(), 'be_attorney_video', true ); | |
if( $videos ) { | |
for( $i = 0; $i < $videos; $i++ ) { | |
$title = esc_html( get_post_meta( get_the_ID(), 'be_attorney_video_' . $i . '_title', true ) ); | |
$video = esc_url( get_post_meta( get_the_ID(), 'be_attorney_video_' . $i . '_video', true ) ); | |
$thumbnail = (int) get_post_meta( get_the_ID(), 'be_attorney_video_' . $i . '_thumbnail', true ); | |
// Thumbnail field returns image ID, so grab image. If none provided, use default image | |
$thumbnail = $thumbnail ? wp_get_attachment_image( $thumbnail, 'be_video' ) : '<img src="' . get_stylesheet_directory_uri() . '/images/default-video.png" />'; | |
// Displayed in two columns, so using column classes | |
$class = 0 == $i || 0 == $i % 2 ? 'one-half first' : 'one-half'; | |
// Build the video box | |
echo '<div class="' . $class . '"><a href="' . $video . '">' . $thumbnail . '</a>' . $title . '</div>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment