-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest-template.php
More file actions
340 lines (258 loc) · 8.73 KB
/
Copy pathtest-template.php
File metadata and controls
340 lines (258 loc) · 8.73 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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
<?php
/**
* Template Name: Test Template
*
* @package MITLibraries-News
* @since 1.0.0
*/
get_header();
?>
<?php get_template_part( 'inc/sub-header' ); ?>
<div class="news-site container">
<section class="bgGrey">
<?php
$sticky = get_option( 'sticky_posts' );
$args = array(
'posts_per_page' => 1,
'post__in' => $sticky,
'ignore_sticky_posts' => 1,
'orderby' => 'menu_order',
'order' => 'ASC',
'suppress_filters' => false,
);
$query2 = new WP_Query( $args );
if ( $query2->have_posts() ) :
while ( $query2->have_posts() ) : $query2->the_post(); ?>
<?php if ( isset( $sticky[0] ) ) { ?>
<div class="row">
<div class="col-md-8" onClick='location.href="<?php echo get_post_permalink(); ?>"' style="padding-right:0px;" > <?php echo get_currentuserinfo(); ?>
<img src="<?php the_field( 'featuredListImg' ) ?> "width="679" height="256" alt="<?php the_title(); ?>" />
</div>
<div class="bgWhite col-xs-12 col-sm-4 col-md-4" onClick='location.href="<?php echo get_post_permalink(); ?>"'>
<h2><?php the_title();?> </h2>
<?php if ( get_field( 'event_date' ) ) { $mitDate = get_field( 'event_date' );
$mitDate = date( 'l t Y', strtotime( $mitDate ) ); ?>
<div class="event"><?php echo $mitDate; ?> <span class="time">
<?php if ( get_field( 'event_start_time' ) ) {
echo the_field( 'event_start_time' );
} ?>
<?php if ( ( get_field( 'event_start_time' ) ) && ( get_field( 'event_end_time' ) ) ) {
echo '-';
} ?>
<?php if ( get_field( 'event_end_time' ) ) {
echo the_field( 'event_end_time' );
} ?>
</span> </div>
<?php } ?>
<!--EVENT -->
<!--/EVENT DATE-->
<div class="excerpt-post">
<p>
<?php if ( excerpt() ) {
echo excerpt( 20 );
} elseif ( content() ) {
echo content( 20 );
}
?>
</p>
</div>
<div class="category-post">
<?php
$category = get_the_category();
if ( $category[0] ) {
echo '<a title="' . $category[0]->cat_name . '" href="' . get_category_link( $category[0]->term_id ) . '">' . $category[0]->cat_name . '</a>';
}
?>
<span class="mitDate"> <?php echo get_the_date(); ?></span>
<!--echo all the cat -->
</div>
</div>
</div>
<?php wp_reset_postdata(); ?>
<?php wp_reset_query(); ?>
<?php } ?>
<?php endwhile; ?>
<?php endif; ?>
<div>
<?php
$args = array(
'posts_per_page' => 9,
'post_type' => array( 'Spotlights','bibliotech', 'post' ),
'post__not_in' => get_option( 'sticky_posts' ),
'ignore_sticky_posts' => 1,
'orderby' => 'menu_order',
'order' => 'ASC',
'suppress_filters' => false,
);
$the_query = new WP_Query( $args );
?>
<div class="row">
<?php if ( $the_query->have_posts() ) : ?>
<?php
while ( $the_query->have_posts() ) : $the_query->the_post();
?>
<div class="col-xs-12 col-sm-4 col-md-4">
<div class="hentry flex-item blueTop eventsBox <?php echo esc_attr( check_image() ); ?>"
onClick='location.href="<?php if ( ( '' != get_field( 'external_link' ) ) && 'spotlights' == $post->post_type ) { the_field( 'external_link' );
} else { echo get_post_permalink();} ?>"'>
<?php if ( 'spotlights' == $post->post_type ) { ?>
<div class="featuredCol">Featured collection</div>
<?php } ?>
<?php if ( 'spotlights' == $post->post_type ) { ?>
<div class="featuredColImg"> <img src="/wp-content/themes/mit-libraries-news/images/info.png" alt="featured" width="31" height="27" /> </div>
<?php } ?>
<?php if ( get_field( 'mark_as_new' ) === true ) : ?>
<div class="newIcon"></div>
<?php endif; ?>
<?php
if ( get_field( 'listImg' ) != '' ) { ?>
<img src="<?php the_field( 'listImg' ) ?>" width="100%" height="111" alt="<?php the_title(); ?>"/>
<h2 class="entry-title title-post"><?php the_title(); ?></h2>
<!--/EVENT DATE-->
<?php if ( get_field( 'event_date' ) ) {
$date = DateTime::createFromFormat( 'Ymd', get_field( 'event_date' ) );
?>
<div class="event"><?php echo $date->format( 'F, j Y' ); ?> <span class="time">
<?php if ( get_field( 'event_start_time' ) ) {
echo the_field( 'event_start_time' );
} ?>
<?php if ( ( get_field( 'event_start_time' ) ) && ( get_field( 'event_end_time' ) ) ) {
echo '-';
} ?>
<?php if ( get_field( 'event_end_time' ) ) {
echo the_field( 'event_end_time' );
} ?>
</span> </div>
<?php } ?>
<!--EVENT -->
<div class="excerpt-post">
<p class="entry-summary">
<?php
$newsTitle = get_the_content();
$newsTitle = strlen( $newsTitle );
if ( ($newsTitle >= 50) && has_excerpt( $post->ID ) ) {
echo excerpt( 30 );
echo 'excertp greater then';
}
?>
</p>
</div>
<?php } elseif ( has_post_thumbnail() ) {
$thumb_id = get_post_thumbnail_id();
$thumb_url_array = wp_get_attachment_image_src( $thumb_id, 'thumbnail-size', true );
$thumb_url = $thumb_url_array[0];?>
<img src="<?php echo $thumb_url; ?>" width="100%" height="200" />
<h2><?php the_title(); ?> </h2>
<!--/EVENT DATE-->
<?php if ( get_field( 'event_date' ) ) {
$date = DateTime::createFromFormat( 'Ymd', get_field( 'event_date' ) );
?>
<div class="event"><?php echo $date->format( 'F, j Y' ); ?> <span class="time">
<?php if ( get_field( 'event_start_time' ) ) {
echo the_field( 'event_start_time' );
} ?>
<?php if ( ( get_field( 'event_start_time' ) ) && ( get_field( 'event_end_time' ) ) ) {
echo '-';
} ?>
<?php if ( get_field( 'event_end_time' ) ) {
echo the_field( 'event_end_time' );
} ?>
</span> </div>
<?php } ?>
<!--EVENT -->
<div class="excerpt-post">
<p class="entry-summary">
<?php if ( excerpt() ) {
echo excerpt( 15 );
} elseif ( content() ) {
echo content( 15 );
}
?>
</p>
</div>
<!--final **** else-->
<?php } else { ?>
<h2 class="entry-title title-postnoImg"> <?php the_title();?> </h2>
<!--/EVENT DATE-->
<?php if ( get_field( 'event_date' ) ) {
$date = DateTime::createFromFormat( 'Ymd', get_field( 'event_date' ) );
?>
<div class="event">
<?php echo $date->format( 'F, j Y' ); ?> <span class="time">
<?php if ( get_field( 'event_start_time' ) ) {
echo the_field( 'event_start_time' );
} ?>
<?php if ( ( get_field( 'event_start_time' ) ) && ( get_field( 'event_end_time' ) ) ) {
echo '-';
} ?>
<?php if ( get_field( 'event_end_time' ) ) {
echo the_field( 'event_end_time' );
} ?>
</span> </div>
<?php } ?>
<!--EVENT -->
<div class="excerpt-post">
<p class="entry-summary">
<?php if ( excerpt() ) {
echo excerpt( 30 );
} elseif ( content() ) {
echo content( 30 );
}
?>
</p>
</div>
<?php } ?>
<div class="category-post <?php if ( get_post_type( get_the_ID() ) == 'bibliotech' ) { echo 'Bibliotech';} ?>">
<?php
if ( get_post_type( get_the_ID() ) == 'bibliotech' ) {
echo "<div class='bilbioImg'><img src='wp-content/themes/mit-libraries-news/images/bilbioTechIcon.png' alt='bilbiotech icon' width='30' height='32' /></div>";
echo "<div class='biblioPadding'> <a href='/news/bibliotech/' title='Bibliotech'>Bibliotech</a>";
} else {
$category = get_the_category();
$rCat = count( $category );
$r = rand( 0, $rCat -1 );
echo '<a title="' . $category[ $r ]->cat_name . '" title="' . $category[ $r ]->cat_name . '" href="' . get_category_link( $category[ $r ]->term_id ) . '">' . $category[ $r ]->cat_name . '</a>';
}
?>
<span class="mitDate"> <time class="updated" datetime="<?php echo get_the_date(); ?>"> <?php echo get_the_date(); ?></time></span> </div>
</div>
</div>
<?php if ( get_post_type( get_the_ID() ) == 'bibliotech' ) { ?>
</div><!--close div that opens in bilbio if statement-->
<?php } ?>
<?php endwhile; ?>
<?php endif; ?>
<?php wp_reset_query(); // Restore global post data stomped by the_post(). ?>
</div>
</div><!--closes ROW-->
</section>
</div>
<div class="container">
<div id="postContainer" class="row" style="display:none">... loading ...</div>
<div class="moreBtn">
<button id="another">Show more</button>
</div>
</div>
<script>
var $j = jQuery.noConflict();
$j(function(){
var offset = 9;
var limit = 9;
$j("#postContainer").load("/news/test/");
$j("#another").click(function(){
limit = limit+9;
offset = offset+9;
$j("#postContainer")
//.slideUp()
.load("/news/test/?offset="+offset+"&limit="+limit, function() {
//.load("/news/test/?offset="+offset, function() {
$j(this).slideDown();
//$j("#another").remove();
});
return false;
});
});
</script>
<?php
get_footer();
?>