-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloop.current.php
69 lines (64 loc) · 2.28 KB
/
loop.current.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
61
62
63
64
65
66
67
68
69
<?php
$pt_name = $pt_current. "s";
$related_out = "";
$exclude = array($post->ID);
$current = time();
$args = array(
'post_type' => $pt_current,
'post__not_in' => $exclude,
'posts_per_page' => -1,
'orderby' => 'meta_value_num',
'meta_key' => '_cedobi_date_ini',
'order' => 'ASC',
'meta_query' => array(
array(
'key' => '_cedobi_date_end',
'value' => $current,
'compare' => '>'
)
)
);
$related_posts = get_posts($args);
if ( count($related_posts) > 0 ) {
$related_tit = sprintf( __( 'Other current %s','cedobi' ), $pt_name );
$related_out .= "
<section class='row'>
<header class='col-sm-24'><h2 class='related-tit'>" .$related_tit. "</h2></header>";
foreach ( $related_posts as $rel_item ) {
$rel_item_tit = $rel_item->post_title;
$rel_item_perma = get_permalink($rel_item->ID);
$rel_item_desc = $rel_item->post_excerpt;
$rel_date_ini = get_post_meta( $rel_item->ID, "_cedobi_date_ini", true );
$rel_date_end = get_post_meta( $rel_item->ID, "_cedobi_date_end", true );
$rel_date_ini_human = date('d \/ m \/ Y',$rel_date_ini);
$rel_date_end_human = date('d \/ m \/ Y',$rel_date_end);
if ( $rel_date_ini_human == $rel_date_end_human ) {
$rel_date_out = "<div class='rel-item-date'>" .$rel_date_ini_human. "</div>";
} else {
$rel_date_out = "<div class='rel-item-date'>" .$rel_date_ini_human. " — " .$rel_date_end_human. "</div>";
}
if ( has_post_thumbnail($rel_item->ID) ) {
$rel_item_img = get_the_post_thumbnail($rel_item->ID,'bigicon',array('class' => 'img-responsive'));
$related_out .= "
<div class='rel-item col-md-24 col-sm-8'><div class='row'>
<div class='rel-item-img col-sm-6'>" .$rel_item_img. "</div>
<div class='rel-item-text col-sm-18'>
<h3 class='rel-item-tit'><a href='" .$rel_item_perma. "'>" .$rel_item_tit. "</a></h3>
" .$rel_date_out. "
<div class='rel-item-desc'>" .$rel_item_desc. "</div>
</div>
</div></div>
";
} else {
$related_out .= "
<div class='rel-item col-md-24'>
<h3 class='rel-item-tit'><a href='" .$rel_item_perma. "'>" .$rel_item_tit. "</a></h3>
" .$rel_date_out. "
<div class='rel-item-desc'>" .$rel_item_desc. "</div>
</div>
";
} // end if related post has thumbnail
} // end loop related posts
$related_out .= "</section>";
} // end if there are related posts
?>