-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcontest.php
More file actions
235 lines (208 loc) · 6.39 KB
/
Copy pathcontest.php
File metadata and controls
235 lines (208 loc) · 6.39 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
<?php
/*
Template Name: Contest
*/
get_header(); ?>
<!-- Start Page Title -->
<section class="wpo-page-title">
<div class="container">
<div class="row">
<div class="col col-xs-12">
<div class="wpo-breadcumb-wrap">
<h2><?php the_title();?></h2>
<ol class="wpo-breadcumb-wrap">
<li><a href="<?php echo home_url(); ?>">Home</a></li>
<li>Gallery</li>
</ol>
</div>
</div>
</div>
</div>
</section>
<!-- End Page Title -->
<div class="container">
<!-- Section Title -->
<div class="row">
<div class="col-lg-7 col-12">
<div class="wpo-section-title text-left mb-5">
<h2>Welcome to the Stack & Hustle Design Challenge Voting!</h2>
</div>
</div>
</div>
<!-- Dynamic Gallery -->
<div class="row space">
<?php
// Query to get posts from the "Gallery" category
$args = array(
'post_type' => 'post',
'category_name' => 'ui-ux-contest', // Category slug
'posts_per_page' => -1, // Display all posts
);
$query = new WP_Query($args);
// Check if there are any posts
if($query->have_posts()):
while($query->have_posts()): $query->the_post();
// Check if the post has a featured image
if(has_post_thumbnail()):
$image_url = get_the_post_thumbnail_url(get_the_ID(), 'full'); // Get the URL of the full-sized image
?>
<!---
<div class="col-md-4 col-sm-6">
<div class="gallery-item" style="height: 460px;">
<img src="<?php echo esc_url($image_url); ?>" alt="<?php the_title(); ?>" class="popup-trigger">
</div>
</div>
--->
<div class="col-md-4 col-sm-6">
<div class="gallery-item" style="height: 460px;">
<img
src="<?php echo esc_url($image_url); ?>"
alt="<?php the_title(); ?>"
class="popup-trigger"
style="width: 200px; height: auto; object-fit: cover; border-radius: 10px; transition: transform 0.3s ease; border: 1px solid #cacaca;"
>
</div>
<h2 style="text-align: center;"><?php the_title();?></h2>
</div>
<?php
else:
echo '<p>No Featured Image for ' . get_the_title() . '</p>';
endif;
endwhile;
wp_reset_postdata();
endif;
?>
</div>
</div>
<!-- Popup Lightbox -->
<div id="customModal" class="popup-modal">
<span class="popup-close">×</span>
<span class="popup-prev">❮</span>
<span class="popup-next">❯</span>
<img id="popupImg" src="" alt="Popup Image" class="popup-modal-content">
</div>
<!-- Styles -->
<style>
/* Add margin-top of 3rem to the .row class */
.space {
margin-bottom: 3rem;
}
/* Gallery item images */
.gallery-item {
width: 100%;
height: 100%;
display: flex;
justify-content: center;
align-items: center;
overflow: hidden;
margin-bottom: 20px;
text-align: left;
}
/* Ensure all images inside .gallery-item are the same size */
.gallery-item img {
width: 100%;
height: 400px;
object-fit: cover;
border-radius: 8px;
transition: transform 0.3s ease;
}
/* Hover effect for images */
.gallery-item img:hover {
transform: scale(1.05); /* Slight zoom effect */
}
.wpo-section-title.text-left.mb-5{
margin-top: 45px;
}
/* Popup overlay and image styles */
.popup-modal {
display: none;
position: fixed;
z-index: 9999;
left: 0;
top: 0;
width: 100%;
height: 100%;
background: rgba(15,15,15,0.95);
text-align: center;
overflow: auto;
padding-top: 60px;
}
.popup-modal-content {
max-width: 90%;
max-height: 80vh;
border-radius: 12px;
box-shadow: 0 8px 25px rgba(0,0,0,0.6);
animation: fadeIn 0.3s ease-in-out;
}
@keyframes fadeIn {
from {opacity: 0; transform: scale(0.95);}
to {opacity: 1; transform: scale(1);}
}
/* Close button */
.popup-close {
position: absolute;
top: 20px;
right: 40px;
color: #fff;
font-size: 40px;
font-weight: bold;
cursor: pointer;
}
.popup-close:hover { color: #FF4A17; }
/* Prev / Next buttons */
.popup-prev, .popup-next {
cursor: pointer;
position: absolute;
top: 50%;
transform: translateY(-50%);
font-size: 35px;
color: #fff;
background: rgba(0,0,0,0.5);
width: 60px;
height: 60px;
line-height: 60px;
text-align: center;
border-radius: 50%;
user-select: none;
transition: all 0.3s;
}
.popup-prev:hover, .popup-next:hover { background: #FF4A17; }
.popup-prev { left: 20px; }
.popup-next { right: 20px; }
</style>
<!-- JavaScript -->
<script>
// Open Modal Image on click
document.addEventListener("DOMContentLoaded", function () {
const modal = document.getElementById("customModal");
const modalImg = document.getElementById("popupImg");
const closeBtn = document.querySelector(".popup-close");
const prevBtn = document.querySelector(".popup-prev");
const nextBtn = document.querySelector(".popup-next");
const images = document.querySelectorAll(".popup-trigger");
let currentIndex = 0;
function openModal(index){
currentIndex = index;
modal.style.display = "block";
modalImg.classList.remove("fadeIn");
void modalImg.offsetWidth; // trigger reflow
modalImg.src = images[currentIndex].src;
modalImg.classList.add("fadeIn");
}
images.forEach((img, index) => {
img.addEventListener("click", () => openModal(index));
});
closeBtn.onclick = () => modal.style.display = "none";
nextBtn.onclick = () => openModal((currentIndex + 1) % images.length);
prevBtn.onclick = () => openModal((currentIndex - 1 + images.length) % images.length);
window.onclick = (e) => { if(e.target === modal) modal.style.display = "none"; }
window.addEventListener("keydown", (e) => {
if(modal.style.display === "block"){
if(e.key === "ArrowRight") nextBtn.click();
if(e.key === "ArrowLeft") prevBtn.click();
if(e.key === "Escape") closeBtn.click();
}
});
});
</script>
<?php get_footer(); ?>