-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloop-mosac.php
107 lines (86 loc) · 3.66 KB
/
loop-mosac.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
// vars depending on the custom post type
if ( $band_pts[$band_count] == 'itinerario' ) {
$item_subtit = "";
$item_date_begin = "";
$item_date_end = "";
$item_icon_id = get_post_meta( $post->ID, '_chuerto_icono_id',true );
if ( $item_icon_id != '' ) {
$item_icon = wp_get_attachment_image( $item_icon_id, 'icon' );
$item_icons_out = "<ul class='list-inline'><li>" .$item_icon. "</li></ul>";
} else { $item_icons_out = ""; }
if ( is_single() ) { $item_desc = get_the_content(); }
else { $item_desc = get_the_excerpt(); }
$item_img_size = "small";
} elseif ( $band_pts[$band_count] == 'badge' ) {
$item_subtit = get_post_meta( $post->ID, '_chuerto_subtit', true );
$item_date_begin = "";
$item_date_end = "";
$item_desc = get_the_excerpt();
$item_icon_id = get_post_meta( $post->ID, '_chuerto_icono_id',true );
if ( $item_icon_id != '' ) {
$item_icon = wp_get_attachment_image( $item_icon_id, 'icon' );
$item_icons_out = "<ul class='list-inline'><li><img src='" .CHUERTO_BLOGTHEME. "/images/chuerto-itinerario-huerto-icono.png' alt='Itinerario Ciudad huerto' /></li></ul>";
} else { $item_icons_out = ""; }
$item_img_size = array(100,100);
} elseif ( $band_pts[$band_count] == 'actividad' ) {
$item_subtit = get_post_meta( $post->ID, '_chuerto_escenario', true );
$item_date_begin = get_post_meta( $post->ID, '_chuerto_date_begin', true );
$item_date_end = get_post_meta( $post->ID, '_chuerto_date_end', true );
$item_date_begin_human = date('d\/m',$item_date_begin);
$item_date_end_human = date('d\/m',$item_date_end);
if ( $item_date_begin_human == $item_date_end_human ) {
$item_date_out = $item_date_begin_human;
} else {
$item_date_out = $item_date_begin_human. "-" .$item_date_end_human;
}
$item_desc = get_the_excerpt();
$second_loop_args = array(
'post_type' => 'badge',
'meta_query' => array(
array(
'key' => '_chuerto_actividades',
'value' => '"' .$post->ID. '"',
'compare' => 'LIKE'
)
)
);
$badges = get_posts($second_loop_args);
if ( count($badges) > 0 ) {
$item_icons_out = "<ul class='list-inline'>";
foreach ( $badges as $badge ) {
$badge_perma = get_permalink( $badge->ID );
$badge_tit = get_the_title( $badge->ID );
$badge_icon_id = get_post_meta( $badge->ID, '_chuerto_icono_id',true );
$badge_icon = wp_get_attachment_image( $badge_icon_id, 'icon' );
$item_icons_out .= "<li><a href='" .$badge_perma. "' title='Badge: " .$badge_tit. "'>" .$badge_icon. "</a></li>";
}
$item_icons_out .= "</ul>";
} else { $item_icons_out = ""; }
$item_img_size = "small";
}
// common vars for all custom post types
$item_perma = get_permalink();
$item_name = get_the_title();
$item_tit = "<h3 class='mosac-item-tit'><a href='" .$item_perma. "' title='" .$item_name. "' rel='bookmark'>" .$item_name. "</a></h3>";
if ( has_post_thumbnail() ) {
$item_logo = "<a href='" .$item_perma. "' title='" .$item_name. "' rel='bookmark'>" .get_the_post_thumbnail($post->ID,$item_img_size,array('class' => 'img-responsive')). "</a>"; } else { $item_logo = "";
}
?>
<article class="mosac-item aligncenter col-md-3 col-sm-3">
<div <?php post_class(); ?>>
<?php echo $item_logo; ?>
<div class="caption">
<?php echo $item_tit; ?>
<?php // subtitle
if ( $item_subtit != '' ) { echo "<div class='mosac-item-subtit'>" .$item_subtit. "</div>"; }
// date
if ( $item_date_begin != '' && $item_date_end != '' ) { echo "<div class='mosac-item-date'>" .$item_date_out. "</div>"; }
// description
if ( $item_desc != '' ) { echo "<div class='mosac-item-desc'>" .$item_desc. "</div>"; }
// icons
if ( $item_icons_out != '' ) { echo "<div class='mosac-item-icons'>" .$item_icons_out. "</div>"; }
?>
</div>
</div>
</article>