Created
September 24, 2015 17:18
-
-
Save joeydsmith/d54ebbd7cb3e05f39e57 to your computer and use it in GitHub Desktop.
This file contains 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 | |
remove_shortcode( 'video' ); | |
add_shortcode('videos', 'videos_shortcode'); | |
add_shortcode('video', 'videos_shortcode'); | |
function videos_shortcode( $atts ) { | |
extract(shortcode_atts(array( | |
'id' => '', | |
'url' => '' | |
), $atts)); | |
$url = str_replace('http://', 'https://', $url); | |
ob_start(); | |
if ( is_array ( parseVideoUrl( $url ) ) ) { | |
echo getVideoOutput( parseVideoUrl( $url ) ); | |
} else { | |
$args = array( | |
'post_type' => 'videos', | |
'post_status' => 'publish', | |
'posts_per_page' => get_option('posts_per_page'), | |
'paged' => $loop->query['page'] | |
); | |
if ( $id ) { | |
$args['p'] = $id; | |
} | |
$loop = new WP_Query( $args ); | |
if ( $id ) { | |
// Define template | |
$template = get_stylesheet_directory() . '/inc/shortcodes/tpl/video.tpl.php'; | |
// Stardard Loop | |
include get_stylesheet_directory() . '/inc/custom-loop-with-template.inc.php'; | |
} else { | |
// Stardard Loop | |
include get_stylesheet_directory() . '/inc/custom-loop.inc.php'; | |
} | |
} | |
return ob_get_clean(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment