<?php
/**
 * Video episodes content
 *
 * @package wpstream-theme
 */

$custom_field_values       = get_post_meta( $post->ID, 'wpstream_bundle_selection', true );
$custom_field_values_array = explode( ',', $custom_field_values );

$wpstream_get_post_type = $post->post_type;
$author_id              = wpstream_get_author_id( $post->ID );
$use_transient          = wpstream_theme_return_use_transient();
$transient_key          = 'wpstream_collection_episodes_' . $author_id;
$post_types_array       = apply_filters( 'wpstream_video_episodes_post_type', array( 'post' ) );

$episodes_collection_query_args = array(
	'post_type'      => $post_types_array,
	'post_status'    => 'publish',
	'posts_per_page' => - 1,
	'orderby' => 'post__in',
	'post__in'       => $custom_field_values_array,
);


$query = wpstream_theme_custom_query( $episodes_collection_query_args, $transient_key, $use_transient );

if ( $query->found_posts > 0 ) { ?>

	<section class="wpstream_section wpstream-episode-content">
		<div class="wpstream-episode-list">
			<?php include get_template_directory() . '/template-parts/single/video-loop-content.php'; ?>
		</div>
	</section>

<?php } ?>
