-
Notifications
You must be signed in to change notification settings - Fork 0
/
page-home.php
242 lines (219 loc) · 6.65 KB
/
page-home.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
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
<?php
/**
* Template Name: Home page
*
* @package YIKES Starter
*/
get_header(); ?>
<?php
$check_paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : 1;
$already_displayed_posts = array();
?>
<div id="main" tabindex="-1" class="site-main" role="main">
<?php if ( 1 === $check_paged ) { ?>
<!-- Home page top section -->
<section class="home-featured-posts">
<div class="container">
<div class="row">
<!-- Newest posts -->
<div class="col-sm-8">
<div class="site-loop home-featured-post-loop">
<h2 class="posts-title">
New Posts <?php echo lwtv_plugin()->get_symbolicon( 'newspaper.svg', 'fa-newspaper' ); ?>
</h2>
<?php
$lastpostloop = new WP_Query(
array(
'posts_per_page' => '1',
'orderby' => 'date',
'order' => 'DESC',
'no_found_rows' => true,
)
);
?>
<!-- // The Loop -->
<?php
while ( $lastpostloop->have_posts() ) :
$lastpostloop->the_post();
$already_displayed_posts[] = get_the_ID();
?>
<div class="card">
<?php
if ( has_post_thumbnail() ) :
?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>" >
<?php the_post_thumbnail( 'large', array( 'class' => 'card-img-top' ) ); ?>
</a>
<?php
endif;
?>
<div class="card-body">
<h3 class="card-title"><?php the_title(); ?></h3>
<div class="card-meta text-muted">
<?php the_date(); ?>
<?php echo lwtv_plugin()->get_symbolicon( 'user-circle.svg', 'fa-user-circle' ); ?>
<?php the_author(); ?>
</div>
<div class="card-text">
<?php the_excerpt(); ?>
</div>
</div><!-- .card-body -->
<div class="card-footer">
<a href="<?php the_permalink(); ?>" class="btn btn-outline-primary">
Read More <span class="screen-reader-text">about <?php the_title(); ?></span>
</a>
</div><!-- .card-footer -->
</div><!-- .card -->
<?php
endwhile;
wp_reset_postdata();
?>
</div>
<div class="site-loop home-featured-secondary-loop">
<?php
$newpostsloop = new WP_Query(
array(
'posts_per_page' => '5',
'offset' => '1',
'orderby' => 'date',
'order' => 'DESC',
'no_found_rows' => true,
)
);
?>
<!-- // The Loop -->
<?php
while ( $newpostsloop->have_posts() ) :
$newpostsloop->the_post();
$already_displayed_posts[] = get_the_ID();
?>
<div class="card-group">
<div class="card col-sm-5"
<?php
if ( has_post_thumbnail() ) {
$alt_src = get_post_meta( get_the_ID(), '_wp_attachment_image_alt', true );
$alt_txt = ( isset( $alt_src ) && '' !== $alt_src ) ? $alt_src : get_the_title();
?>
style="background-image: url(<?php the_post_thumbnail_url( 'large' ); ?>);"
<?php
}
?>
>
</div>
<div class="card col-sm-7">
<div class="card-body">
<h3 class="card-title"><?php the_title(); ?></h3>
<div class="card-meta text-muted">
<?php the_date(); ?>
<?php echo lwtv_plugin()->get_symbolicon( 'user-circle.svg', 'fa-user-circle' ); ?>
<?php the_author(); ?>
</div>
<div class="card-text">
<?php the_excerpt(); ?>
</div>
</div>
<div class="card-footer">
<a href="<?php the_permalink(); ?>" class="btn btn-sm btn-outline-primary">
Read More <span class="screen-reader-text">about <?php the_title(); ?></span>
</a>
</div>
</div><!-- .card -->
</div><!-- .card-group -->
<?php
endwhile;
wp_reset_postdata();
?>
</div><!-- .home-featured-secondary-loop -->
</div><!-- .col-sm-8 -->
<!-- Home Page Sidebar -->
<div class="col-sm-4 site-sidebar site-loop">
<?php dynamic_sidebar( 'sidebar-1' ); ?>
</div>
</div><!-- .row -->
</div><!-- .container -->
</section>
<!-- Shows We Love -->
<section class="home-featured-shows">
<div class="container">
<div class="row">
<div class="col">
<h2>Shows We Love <?php echo lwtv_plugin()->get_symbolicon( 'hearts.svg', 'fa-heart' ); ?></h2>
</div>
</div>
<?php
$class = ( 1 === $check_paged ) ? '' : 'four-across-loop';
?>
<div class="row site-loop shows-we-love-loop <?php echo esc_attr( $class ); ?>">
<?php
// Collect 30 loved posts (max) and then pick 3.
$lovedpostloop = new WP_Query(
array(
'post_type' => 'post_type_shows',
'posts_per_page' => '30',
'post_status' => array( 'publish' ),
'no_found_rows' => true,
'_loved_shuffle' => 3,
'meta_query' => array( // phpcs:ignore WordPress.DB.SlowDBQuery -- Risk of slow query accepted.
array(
'key' => 'lezshows_worthit_show_we_love',
'value' => 'on',
'compare' => '=',
),
),
)
);
while ( $lovedpostloop->have_posts() ) :
$lovedpostloop->the_post();
?>
<?php get_template_part( 'template-parts/content/loved' ); ?>
<?php
endwhile;
wp_reset_postdata();
?>
<!-- End Loop -->
</div><!-- .row -->
</div><!-- .container -->
</section>
<?php } ?>
<!-- Older Posts -->
<section class="home-older-posts">
<div class="container">
<div class="row">
<div class="col">
<h2 class="posts-title">
More Posts <?php echo lwtv_plugin()->get_symbolicon( 'newspaper.svg', 'fa-newspaper' ); ?>
</h2>
</div>
</div>
<?php
$class = ( 1 === $check_paged ) ? '' : 'four-across-loop';
?>
<div class="row site-loop main-posts-loop <?php echo esc_attr( $class ); ?>">
<?php
$old_posts_per_page = ( 1 === $check_paged ) ? '6' : '12';
$oldpostsloop = new WP_Query(
array(
'posts_per_page' => $old_posts_per_page,
'paged' => $check_paged,
'post__not_in' => $already_displayed_posts,
'orderby' => 'date',
'order' => 'DESC',
)
);
?>
<!-- // The Loop -->
<?php
while ( $oldpostsloop->have_posts() ) :
$oldpostsloop->the_post();
?>
<?php get_template_part( 'template-parts/content/posts' ); ?>
<?php
endwhile;
wp_reset_postdata();
?>
</div><!-- .row .home-featured-post-loop -->
<?php yikes_generate_pagination_buttons( $check_paged, $oldpostsloop->max_num_pages ); ?>
</div><!-- .container -->
</section>
</div><!-- #main -->
<?php get_footer(); ?>