shortcodes-contest.php
3.57 KB
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
107
108
109
110
111
112
113
114
115
116
<?php
add_shortcode('contest-slider', 'contest_slider');
function contest_slider(){
$custom_args = array(
'post_type' => 'nf_sub',
'posts_per_page' => -1,
'paged' => 1,
'post_status' => 'any',
'order' => 'DESC',
'orderby' => 'rand',
'meta_query' => array(
'relation' => 'AND',
array(
'key' => '_form_id',
'value' => '2',
'compare' => '=',
),
),
);
$custom_query = new \WP_Query($custom_args);
ob_start();
$uniqid = uniqid();
if ($custom_query->have_posts()): ?>
<div class="swiper-container">
<div class='swiper-wrapper'>
<?php while ($custom_query->have_posts()): $custom_query->the_post(); ?>
<div class="swiper-slide">
<?php $image = get_post_meta(get_the_ID(), '_field_9', true );
$num = get_post_meta(get_the_ID(), '_seq_num', true );
$cap = get_post_meta(get_the_ID(), '_field_7', true );
?>
<img src="<?php echo $image[$num];?>" alt="<?php echo $cap;?>">
<div class="contest_cap"><?php echo $cap;?></div>
</div>
<?php endwhile; ?>
</div>
<div class="swiper-button-prev"></div>
<div class="swiper-button-next"></div>
</div>
<style>
.swiper-container{
width: 100%;
position: relative;
overflow: hidden;
height: 250px;
margin-right: 0px;
padding-right: 0px;
}
.swiper-wrapper {
width: 100%;
}
.swiper-slide {
text-align: left;
width: auto;
}
.swiper-slide img{
height: 185px;
width: auto;
}
.swiper-button-next, .swiper-rtl .swiper-button-prev{
z-index: 9999;
}
.swiper-button-prev, .swiper-rtl .swiper-button-next {
left: unset;
right: 32px;
bottom: 0px;
top: unset;
width: 32px;
height: 32px;
font-size: 26px;
background-color:#1A3668;
margin-right:6px;
}
.swiper-button-next, .swiper-rtl .swiper-button-prev{
left: unset;
right: 0px;
bottom: 0px;
top: unset;
width: 32px;
height: 32px;
background-color:#1A3668;
}
.swiper-button-prev:hover,
.swiper-button-next:hover{
background-color:#132C55;
}
.swiper-button-prev:after,
.swiper-button-next:after{
font-size: 20px;
color:#fff;
}
.contest_cap{
color:#000;
font-size:20px;
margin-top:-40px;
margin-left:20px;
}
</style>
<?php endif;
wp_reset_query();
$output = ob_get_clean();
return $output;
}