-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtemplate.php
60 lines (54 loc) · 1.47 KB
/
template.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
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
* example usage:
*
* if ( has_featured_media_video() ) {
* $video = get_featured_media_video();
* echo $video->get_embed_code( array(
* 'width' => 400,
* 'height' => 300
* ) );
* }
*
*/
function has_featured_media_video( $post_id = null ) {
$video = new \FeaturedMedia\PostVideo( $post_id );
$url = $video->get_url();
return !empty( $url );
}
function get_featured_media_video( $post_id = null ) {
if ( has_featured_media_video( $post_id ) )
return new \FeaturedMedia\PostVideo( $post_id );
else
return null;
}
/**
* example usage:
*
* if ( has_featured_media_gallery() ) {
* $gallery = get_featured_media_gallery();
* foreach ( $gallery as $image ) {
* $src = wp_get_attachment_image_src( $image, 'medium' );
* printf( '<img src="%s" alt="">', $src[0] );
* }
* }
*
*/
function has_featured_media_gallery( $post_id = null ) {
$gallery = get_featured_media_gallery( $post_id );
return !empty( $gallery );
}
function get_featured_media_gallery( $post_id = null ) {
$post = get_post( $post_id );
$gallery_items = get_post_meta( $post->ID, '_featured-media-gallery', true );
if ( empty( $gallery_items ) )
return false;
else
return $gallery_items;
}
function has_featured_media_thumbnail( $post_id ) {
return has_post_thumbnail( $post_id );
}
function get_featured_media_thumbnail( $post_id, $size = null ) {
return get_the_post_thumbnail( $post_id, $size );
}