Creare un Loop di video è un'operazione semplice in WordPress.
La soluzione è la seguente (in functions.php):
function my_get_videos() {
$output = '';
$videos = get_posts( array(
'post_type' => 'attachment',
'posts_per_page' => 10,
'post_mime_type' => array( 'video/mpeg' )
) );
if ( $videos ) {
foreach ( $videos as $video ) {
$video_url = wp_get_attachment_url( $video->ID );
$output .= '<video src="' . $video_url . '"></video>';
}
}
return $output;
}
Esempio d'uso:
<?php echo my_get_videos(); ?>