-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideos-filter.php
49 lines (40 loc) · 1.16 KB
/
videos-filter.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
// the_content();
$section = $_GET['sections'];
$categories = $_GET['categories'];
$tags = $_GET['tags'];
$content = $_GET['contents'];
$cats = $section . ',' . $categories . ',' . $tags;
$args = array(
'post_type' => 'attachment',
'post_mime_type' =>'video',
'post_status' => 'inherit',
'orderby' => 'date',
'posts_per_page' => -1
);
if ( $cats !== ',,') {
$args['category_name'] = $cats;
}
$query_vids = new WP_Query( $args );
$vids = array();
foreach ( $query_vids->posts as $vid) {
$vids[]= $vid;
}
foreach ( $vids as $vid ) {
$id = $vid->ID;
$thumb = get_the_post_thumbnail($id); // returns as full img tag
$href = get_attachment_link($id);
$title = get_the_title($id);
$video_meta = wp_get_attachment_metadata($id);
if ( $thumb ) { ?>
<div class="video-thumnails">
<a href="<?php echo $href; ?>">
<?php echo $thumb; ?>
<span class="video-title"><?php echo $title; ?> | <?php echo $video_meta['length_formatted']; ?>
<?php if ( $vid->post_excerpt) { echo '<p class="video-caption">' . $vid->post_excerpt . '</p>'; } ?>
</span>
</a>
</div>
<?php }
}
?>