-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.php
138 lines (108 loc) · 3.86 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
<?php get_header(); ?>
<div class="news-outer">
<div class="news-top">
<div class="news-top-inner">
<?php if(is_category()) : ?>
<h1><a href="<?php echo get_post_type_archive_link( 'post' ); ?>"><?php _e('NEWS & EVENTS','all_wp_theme'); ?></a> <span>/ <?php single_cat_title(); ?></span></h1>
<?php elseif(is_tag()) : ?>
<h1><a href="<?php echo get_post_type_archive_link( 'post' ); ?>"><?php _e('NEWS & EVENTS','all_wp_theme'); ?></a> <span>/ <?php single_tag_title(); ?></span></h1>
<?php else : ?>
<h1><?php _e('NEWS & EVENTS','all_wp_theme'); ?></h1>
<?php endif; ?>
<div class="mobile-filter-outer">
<?php echo get_template_part('partials/section','search-form'); ?>
<a href="#" class="filter-trigger">
<svg width="26" height="24" viewBox="0 0 26 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M0 2H26V4H0V2ZM0 11H26V13H0V11ZM26 20H0V22H26V20Z" fill="black"/>
<circle cx="9" cy="3" r="3" fill="#F9F9F9"/>
<circle cx="9" cy="21" r="3" fill="#F9F9F9"/>
<circle cx="9" cy="3" r="2" fill="black"/>
<circle cx="19" cy="12" r="3" fill="#F9F9F9"/>
<circle cx="19" cy="12" r="2" fill="black"/>
<circle cx="9" cy="21" r="2" fill="black"/>
</svg>
</a>
</div>
</div>
</div>
<div class="news-content">
<main>
<?php
if(is_category()) {
$args = array(
'post_type' => 'post',
'posts_per_page' => 6,
'cat' => get_query_var( 'cat' ),
);
} elseif(is_tag()) {
$args = array(
'post_type' => 'post',
'posts_per_page' => 6,
'tag_id' => $tag_id,
);
} else {
$args = array(
'post_type' => 'post',
'posts_per_page' => 6
);
}
$the_query = new WP_Query($args);
$total = $the_query->found_posts;
if ($the_query->have_posts()) {
?>
<div class="blog-roll regular"
data-id="<?php if(is_category()){ echo get_query_var( 'cat' ); } elseif(is_tag()) { echo $tag_id; }?>"
data-posttype="<?php if(is_category()){ echo 'category'; } elseif(is_tag()) { echo 'tag'; } else { echo 'all'; } ?>" data-counter="<?php echo $total; ?>"
>
<?php while ($the_query->have_posts()) { $the_query->the_post(); ?>
<?php echo get_template_part('partials/item','news'); ?>
<?php } ?>
</div>
<?php
if($total > 5) :
?>
<div class="load-more">
Show More
</div>
<?php endif; ?>
<?php } wp_reset_postdata(); ?>
</main>
<aside id="news-scroll-indicator">
<?php get_sidebar(); ?>
</aside>
</div>
<?php if(wp_is_mobile()) { ?>
<?php
$lastest = new WP_Query(array(
'post_type' => 'post',
'posts_per_page' => 3
));
if ($lastest->have_posts()) : ?>
<div class="widget widget-mobile-only">
<h3>Most Recent Stories</h3>
<ul class="aside-post-list">
<?php
while ($lastest->have_posts()) : $lastest->the_post();
$title = get_the_title();
$trimmTitle = substr($title,0,50).'...';
?>
<li>
<?php $featured_img_url = get_the_post_thumbnail_url(get_the_ID(),'thumbnail'); ?>
<a href="<?php the_permalink(); ?>" class="thumb-outer">
<figure <?php if ( has_post_thumbnail() ) { ?>class="has-image"<?php } ?>>
<?php if ( has_post_thumbnail() ) { ?><img src="<?php echo $featured_img_url; ?>" alt="<?php the_title(); ?>"><?php } ?>
</figure>
</a>
<hgroup>
<h4><a href="<?php the_permalink(); ?>"><?php echo $trimmTitle; ?></a></h4>
<p class="meta"><?php the_time('jS F Y'); ?></p>
</hgroup>
</li>
<?php endwhile; ?>
</ul>
</div>
<?php endif; wp_reset_postdata(); ?>
<?php } ?>
</div>
<?php echo get_template_part('partials/section','footer'); ?>
<?php get_footer(); ?>