-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathindex.php
163 lines (163 loc) · 6.26 KB
/
index.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
<?php
/*
Template Name: 默认首页
*/
get_header();?><?php
$excludeIDs = get_option('index_newes_exclude');
$minius_excludeIDs = array();
if ($excludeIDs) {
foreach ($excludeIDs as $id) {
$minius_excludeIDs[] = '-'.(string)$id;
}
}$cpids = array();
if (get_option('headLine_random') != "checked") {
$carouselPostIDs = get_option("headLine");
if (gettype($carouselPostIDs) == "array") {
foreach ($carouselPostIDs as $post) {
$cpids[] = $post["post"];
}
}
} else {
$args = array(
'posts_per_page' => 7,'orderby' => 'rand','cat' => $minius_excludeIDs,'ignore_sticky_posts' => true
);
$carouselsID_query = new WP_Query();
$carouselsID_query->query($args);
while ($carouselsID_query->have_posts()) {
$carouselsID_query->the_post();
$cpids[] = $post->ID;
}wp_reset_query();
}get_topSlider($cpids, _opt('frontpage_carousels_type'));?>
<div class="container postListsModel">
<div class="row"><?php
if (_opt('frontpage_hide_sidebar')=='checked') {
$leftClass = 'col-xs-12 no-sidebar';
$rightClass = 'hidden';
} else {
$leftClass = 'col-md-9 col-lg-9_5';
$rightClass = 'col-md-3 col-lg-2_5 hidden-xs hidden-sm';
}?>
<div class="<?php echo $leftClass; ?>"><?php
global $nav_category_list_type;
$nav_category_list_type = _opt('frontpage_postlist_type', 'lists');
include('assets/template/nav-category.php');?>
<div class="col-xs-12">
<div class="row"><?php $listType = _opt('frontpage_postlist_type', 'lists'); ?>
<div class="row postLists <?php echo $listType; ?> <?php echo(_opt('enable_post_list_waterfall') ? 'waterfall' : ''); ?>" height-to="sidebar"><?php
$newest_num = intval(get_option('frontpage_postlist_newest_num'));
$like_num = intval(get_option('frontpage_postlist_like_num'));
$comment_num = intval(get_option('frontpage_postlist_comment_num'));
$random_num = intval(get_option('frontpage_postlist_random_num'));
$ids = array();
if ($newest_num > 0) {
$args = array(
'post_type' => 'post','cat' => $minius_excludeIDs,'post_status' => 'publish','post__not_in' => $ids,//排除已筛选的文章
'posts_per_page' => $newest_num,);
$query_posts = new WP_Query();
$query_posts->query($args);
$i = $newest_num;
while ($query_posts->have_posts() && $i > 0) {
$query_posts->the_post();
$ids[] = $post->ID;
$i--;
}wp_reset_query();
}if ($like_num > 0) {
$args = array(
'post_type' => 'post','cat' => $minius_excludeIDs,'post_status' => 'publish','post__not_in' => $ids,//排除已筛选的文章
'posts_per_page' => $like_num,'ignore_sticky_posts' => true,'meta_query' => array(array('key' => 'bigfa_ding','type' => 'NUMERIC'
),),'orderby' => array(
'bigfa_ding' => 'DESC',),);
$query_posts = new WP_Query();
$query_posts->query($args);
while ($query_posts->have_posts()) {
$query_posts->the_post();
$ids[] = $post->ID;
}wp_reset_query();
}if ($comment_num > 0) {
$args = array(
'post_type' => 'post','cat' => $minius_excludeIDs,'post_status' => 'publish','post__not_in' => $ids,//排除已筛选的文章
'posts_per_page' => $comment_num,'orderby' => 'comment_count','ignore_sticky_posts' => true
);
$query_posts = new WP_Query();
$query_posts->query($args);
while ($query_posts->have_posts()) {
$query_posts->the_post();
$ids[] = $post->ID;
}wp_reset_query();
}if ($random_num > 0) {
$args = array(
'post_type' => 'post','cat' => $minius_excludeIDs,'post_status' => 'publish','post__not_in' => $ids,//排除已筛选的文章
'posts_per_page' => $random_num,'orderby' => 'rand','ignore_sticky_posts' => true
);
$query_posts = new WP_Query();
$query_posts->query($args);
while ($query_posts->have_posts()) {
$query_posts->the_post();
$ids[] = $post->ID;
}wp_reset_query();
}$newestIds = array();
$otherIds = array();
for ($i=0; $i < count($ids); $i++) {
if ($i < $newest_num) {
$newestIds[] = $ids[$i];
} else {
$otherIds[] = $ids[$i];
}
}shuffle($otherIds);
$ids = array_merge($newestIds, $otherIds);
global $post;
foreach ($ids as $id) {
$post = get_post($id);
setup_postdata($post);?>
<div class="col-xxs-6 col-xs-4 col-lg-3 post-card-wrapper"><?php include('assets/template/postlist-post.php'); ?></div><?php
}?>
</div>
</div>
<div class="row postLists"><?php
if (_opt('index_time_url')) {
echo '<div class="col-xs-12 readMore"><a href="'._opt('index_time_url').'">
'._opt('read_more_text', '阅读更多').'
<i class="fas fa-chevron-down"></i></a></div>';
}?></div>
</div>
</div>
<div class="<?php echo $rightClass; ?>">
<div class="row">
<div class="sidebar">
<div manual-template="sidebarMenu"></div>
<div manual-template="sidebar" height-from="postLists"></div>
</div>
</div>
</div>
</div>
</div>
<div class="long-model-wrapper"><?php
$index_group = _opt('index_group', array());
foreach ($index_group as $group) {
$catIDs = array();
if ($group['cats']) {
foreach ($group['cats'] as $id_num) {
$catIDs[] = (string)$id_num;
}
}$post_number = intval($group['num']) ? intval($group['num']) : 6;
$args = array(
'post_type' => 'post','cat' => $catIDs,'orderby' => 'rand','posts_per_page' => $post_number,'ignore_sticky_posts' => true
);
$query_posts = new WP_Query();
$query_posts->query($args);
$post_num_class = 'posts-'.$group['num'];?>
<div class="long-model <?php echo $post_num_class; ?>">
<div class="container"><span class="model-title"><?php echo $group['name']; ?></span><?php
if ($group['href']) {?><a class="more" href="<?php echo $group['href']; ?>"><?php echo($group['more'] ? $group['more'] : '阅读更多'); ?><i class="fas fa-angle-right"></i></a><?php
}?>
<div class="row postLists <?php echo $group['type']; ?>"><?php
while ($query_posts->have_posts()) {
$query_posts->the_post();?>
<div class="col-xxs-6 col-xs-4 col-md-3 post-card-wrapper"><?php include('assets/template/postlist-post.php'); ?></div><?php
}?>
</div>
</div>
</div><?php
}?>
</div><?php get_footer(); ?><?php
?>