-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathindex.php
More file actions
165 lines (132 loc) · 3.46 KB
/
Copy pathindex.php
File metadata and controls
165 lines (132 loc) · 3.46 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
<?php
/**
* This is the main index of news posts, divided into two sections. The
* first is for sticky posts, followed by everything else. The two sections
* are separated into two adjacent div elements.
*
* @package MITLibraries-News
* @since Twenty Twelve 1.0
*/
$pageRoot = getRoot( $post );
$section = get_post( $pageRoot );
$isRoot = $section->ID == $post->ID;
/**
* The $post_count variable is used to record how many stories were loaded
* on the initial page load (since the number of sticky stories is variable).
* This is then passed to the pagination routine to ensure smooth progression
* from the first to second pages.
*/
$post_count = 0;
get_header();
get_template_part( 'inc/sub-header' );
// This sets up the upper region of the list, for "Featured" posts.
?>
<div class="wrap-sticky">
<!-- OPEN CONTAINER FOR MOBILE/STICKY CARD LAYOUT -->
<div class="container container-fluid">
<!-- OPEN ROW FOR MOBILE/STICKY CARD LAYOUT -->
<div class="row">
<h3 class="header-section sticky">Featured news</h3>
<?php
// This builds the query for the upper region.
$sticky = get_option( 'sticky_posts' );
$args = array(
'posts_per_page' => 7,
'post__in' => $sticky,
'post_type' => array(
'spotlights',
'bibliotech',
'post',
),
'ignore_sticky_posts' => 1,
'orderby' => 'post_date',
'order' => 'DESC',
'suppress_filters' => false,
);
$sticky_query = new WP_Query( $args );
if ( $sticky_query->have_posts() ) :
$i = 1; // $i is a counter variable.
while ( $sticky_query->have_posts() ) :
$sticky_query->the_post();
if ( 1 == $i ) {
// The first card is rendered as a feature.
renderMobileCard( $i, $post );
renderFeatureCard( $i, $post );
} else {
// All other cards are rendered normally.
renderRegularCard( $i, $post );
}
$i++;
$post_count++;
endwhile;
// This resets the query.
wp_reset_postdata();
wp_reset_query();
endif;
?>
</div> <!-- Closes row. -->
</div> <!-- Closes container. -->
</div> <!-- Closes wrap-sticky. -->
<div class="wrap-regular">
<!-- OPEN CONTAINER FOR REGULAR CARD LAYOUT -->
<div class="container container-fluid">
<!-- OPEN ROW FOR REGULAR CARD LAYOUT -->
<div class="row">
<?php
$args = array(
'posts_per_page' => 9,
'post__not_in' => $sticky,
'post_type' => array(
'spotlights',
'bibliotech',
'post',
),
'ignore_sticky_posts' => 1,
'orderby' => 'post_date',
'order' => 'DESC',
'suppress_filters' => false,
);
$standard_query = new WP_Query( $args );
if ( $standard_query->have_posts() ) :
// $theLength = $count_posts->publish;
$i = -1;
while ( $standard_query->have_posts() ) :
$standard_query->the_post();
$i++;
renderRegularCard( $i, $post ); // --- CALLS REGULAR CARDS --- //
$post_count++;
endwhile;
wp_reset_query(); // Restore global post data stomped by the_post().
endif;
?>
</div>
<!--closes ROW-->
</div>
<!--closes NEWS-CONTAINER-->
<?php
if ( $i > 6 ) {
get_template_part( 'inc/more-posts' );
} //$i > 6
?>
</div>
<!--closes WRAP-REGULAR-->
<script>
$(document).ready(function() {
var offset = <?php echo esc_js( $post_count ); ?>;
var limit = 9;
$("#postContainer").load("/news/test/");
$("#another").click(function(){
limit = limit+9;
offset = offset+9;
$("#postContainer")
//.slideUp()
.load("/news/test/?offset="+offset+"&limit="+limit, function() {
//.load("/news/test/?offset="+offset, function() {
$(this).slideDown();
});
return false;
});
});
</script>
<div class="container container-fluid">
<?php get_footer(); ?>