-
Notifications
You must be signed in to change notification settings - Fork 0
/
search-nw.php
233 lines (153 loc) · 5.63 KB
/
search-nw.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
<?php
/**
* The template for displaying member search results pages
*
* @link https://developer.wordpress.org/themes/basics/template-hierarchy/#search-result
*
* @package cap2019
*/
get_header();
// $paged - number of the current page
global $paged, $wp_query;
$paged = ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1;
$s = cap_return_member_search_query();
?>
<div id="primary" class="primary primary--search content-area">
<main id="main" class="site-main container">
<div class="cap-search__main flex-container">
<div class="cap-search__posts flex-item">
<?php
if ( have_posts() ) : ?>
<header class="page-header">
<h1 class="page-title">
<?php
/* translators: %s: search query. */
printf( esc_html__( 'Search Results for: %s', 'cap' ), '<span>' . $s . '</span>' );
?>
</h1>
</header><!-- .page-header -->
<div class="wrap--no-stickies <?php if ( empty( $search_stickies ) ) echo ' beware-no-stickies'; ?>">
<div class="no-stickies">
<?php
$unst_i = 0;
while ( have_posts() ) :
the_post();
$ID = get_the_ID();
$title = get_the_title( $ID );
$content = $post->post_content;
$excerpt = wp_strip_all_tags(
cap_custom_excerpt(
$content,
50,
get_permalink(),
''
)
);
$permalink = get_the_permalink( $ID );
$thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $ID ), 'cap-single-thumbnail' );
$thumb = filter_var( $thumb[0], FILTER_VALIDATE_URL )
? $thumb[0]
: get_template_directory_uri() . '/img/default-thumb.jpg';
$country = get_field('net_country');
$has_country = ( $country && ( '' !== $country ) );
$prof = get_field('net_profcat');
$has_prof = ( $prof && ( '' !== $prof ) );
?>
<div class="no-sticky flex-container">
<div class="no-sticky__left flex-item">
<?php
if ( $has_prof || $has_country ) : ?>
<div class="no-sticky__meta flex-container">
<?php if ( $has_prof ) : ?>
<div class="member-meta__prof flex-item flex-container">
<?php echo $prof; ?>
</div>
<?php endif;
if ( $has_country ) : ?>
<div class="member-meta__country flex-item flex-container">
<span>from</span>
<?php echo $country; ?>
</div>
<?php
endif; ?>
</div>
<?php
endif; ?>
<h2 class="no-sticky__title"><a href="<?php echo $permalink; ?>"><?php echo relevanssi_get_the_title( $ID ); ?></a></h2>
<div class="no-sticky__excerpt"><?php echo $excerpt; ?></div>
</div>
<div class="no-sticky__right flex-item">
<div class="wrap--no-sticky__thumb">
<div class="no-sticky__thumb">
<a href="<?php echo $permalink; ?>"><?php the_post_thumbnail( 'member-thumbnail' ); ?></a>
</div>
</div>
</div>
</div>
<?php
if ( ( $unst_i == 4 ) && ( $paged == 1 ) ) :
$btitle = get_field( 'cap_general_arch_cobustitle', 'option' );
$btitle = ( $btitle && ( '' !== $btitle ) )
? $btitle
: false;
cap_blog_inbetween_cobus( false, $btitle );
endif;
$unst_i++;
endwhile;
wp_reset_postdata();
/**
* PAGINATION
* ==========
*/
// $paged is defined at the top - it's needed elsewhere as
// well in the code, not only in pagination.
$total_pages = $wp_query->max_num_pages;
$big = 999999999; // need an unlikely integer
$current_page = max(1, $paged);
$pargs = array(
'prev_text' => '<span class="cap-pagination__prev dashicons dashicons-arrow-left-alt2"></span>',
'next_text' => '<span class="cap-pagination__prev dashicons dashicons-arrow-right-alt2"></span>',
// Using 'type' => 'array' you can remove
// page links by using unset().
// E.g.: unset( $links[ $total_pages - 7 ] ) -
// just don't forget to set the $total_pages
// value, see below;
'type' => 'array',
'mid_size' => 1,
'end_size' => 1,
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => $current_page,
'total' => $total_pages,
'paged' => $paged,
);
if ($total_pages > 1) :
$links = paginate_links($pargs);
echo '<div class="wrap--cap-pagination"><div class="cap-pagination">';
// Add "Page x of X" info span
echo "<span class='page-numbers pageof-info'>Page {$paged} of {$total_pages}</span>";
foreach ( $links as $link ) echo $link;
echo '</div></div>';
endif;
?>
</div>
</div>
<?php
else:
get_template_part( 'template-parts/content', 'none-nw' );
endif; ?>
</div>
<div class="cap-search__sidebar flex-item">
<?php
if ( is_active_sidebar( 'sidebar-11' ) ) : ?>
<aside id="secondary" class="widget-area">
<?php dynamic_sidebar( 'sidebar-11' ); ?>
</aside><!-- #secondary -->
<?php
endif; ?>
</div>
</div>
</main><!-- #main -->
</div><!-- #primary -->
<?php
get_footer();