-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.php
164 lines (123 loc) · 3.56 KB
/
search.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
<?php
get_header();
$post_type = 'any';
if ( isset( $_GET['post_type'] ) && ! empty( $_GET['post_type'] ) ) {
$post_type = $_GET['post_type'];
}
// Check pagination
if ( ! is_post_type_archive( 'post' ) ) :
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;;
$category = strtolower(single_cat_title( '', false ));
if (is_category( )) {
$cat = get_query_var('cat');
$curCat = get_category ($cat);
$category = $curCat->slug;
}
$postPerPage = get_option( 'posts_per_page' );
$args = array(
'post_type' => array( $post_type ),
'order_by' => 'post_date',
'order' => 'DESC',
'posts_per_page' => $postPerPage,
'paged' => $paged,
'category_name' => $category
);
$the_query = new WP_Query( $args );
endif;
?>
<section id="archive">
<section class="container">
<div class="col-md-12">
<?php ais_breadcrumb( get_post_type( $post ) ); ?>
</div>
<div class="col-md-8">
<?php
if ( have_posts() ) :
?>
<div class="archive-item">
<?php
while ( have_posts() ) : the_post();
$categories = get_the_category();
if ( ! empty( $categories ) ) {
foreach ( $categories as $key => $value ) {
if ( 'special-offers' == $value->category_nicename || 'events-promotions' == $value->category_nicename ) {
$label = $value->name;
}
}
}
?>
<article id="entry" class="col-md-12 nopad">
<div class="col-md-6 nopad entry-img-container">
<a href="<?php the_permalink(); ?>">
<?php
if ( has_post_thumbnail() ) :
the_post_thumbnail( 'xx-landscape', array( 'class' => 'img-featured-list' ) );
endif;
?>
<div class="article-fg"></div>
<div class="article-shadow"></div>
<div class="article-date"><?php the_time('d F Y'); ?></div>
</a>
</div>
<div class="col-md-6">
<h3 class="entry-title">
<a href="<?php the_permalink(); ?>">
<?php the_title(); ?>
</a>
</h3>
<div class="entry-content">
<?php ais_excerpt_length( 30, get_the_permalink(), 'read-more', 'Read more' ); ?>
</div>
<div class="entry-notes text-right">
<span class="fa fa-tags"></span>
<?php the_category( ', ' ); ?> by
<?php the_author_posts_link(); ?>
</div>
</div>
</article>
<?php
endwhile;
?>
<div class="row">
<div class="col-md-12 text-center">
<nav class="pagination">
<?php
if ( !is_post_type_archive( 'post' ) ) :
global $wp_query;
$total = $wp_query->max_num_pages;
else :
$total = $the_query->max_num_pages;
endif;
$big = 999999999;
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $total,
'prev_text' => '<span aria-hidden="true">«</span>',
'next_text' => '<span aria-hidden="true">»</span>',
) );
?>
</nav>
</div>
</div>
</div>
<?php
else :
?>
<div class="row">
<div class="text-center">
<h2 class="no-post-found">Sorry, no posts match with your criteria.</h2>
<div class="col-md-offset-3 col-md-6">
<?php get_search_form( true ); ?>
</div>
</div>
</div>
<?php endif; ?>
</div>
<div class="col-md-4">
<?php get_sidebar(); ?>
</div>
</section>
</section>
<?php get_footer(); ?>