-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsearch.php
More file actions
59 lines (53 loc) · 1.59 KB
/
Copy pathsearch.php
File metadata and controls
59 lines (53 loc) · 1.59 KB
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
<?php
/**
* Template Name: Search Page
*/
get_header(); ?>
<div class="whatpageisthis">search.php</div>
<div class="row">
<main class="span8" id="content">
<h1 class="inner-heading">
<?php
$search_query = get_search_query();
$allsearch = new WP_Query(array(
's' => $search_query,
'posts_per_page' => -1,
'post_status' => 'publish'
));
$count = $allsearch->post_count;
?>
Search Results
<small hidden>(<?php echo $count; ?> results)</small>
<?php wp_reset_postdata(); ?>
</h1>
<?php
// Main paginated search query
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$search_results = new WP_Query(array(
's' => $search_query,
'posts_per_page' => 10,
'paged' => $paged,
'post_status' => 'publish'
));
if ( $search_results->have_posts() ) :
while ($search_results->have_posts()) : $search_results->the_post();
if( !get_post_format() ) {
get_template_part('format', 'standard');
} else {
get_template_part('format', get_post_format());
}
endwhile;
wp_reset_query();
// Pagination
get_pagination($search_results);
wp_reset_postdata();
else : ?>
<div class="alert alert-block" id="no-search-results">
<h2>Oh, snap!</h2>
We couldn't find any pages or content with the keywords you searched for.
</div>
<?php endif; ?>
</main><!-- span8 #content -->
<?php get_sidebar(); ?>
</div><!-- row -->
<?php get_footer(); ?>