-
Notifications
You must be signed in to change notification settings - Fork 0
/
search.php
91 lines (63 loc) · 2.02 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
<?php get_header(); ?>
<main>
<section class="section-padding">
<div class="row">
<div class="col span-8 col-margin">
<?php if(have_posts()) : ?>
<?php
// Search result count
$num_results = $wp_query->found_posts;
$result_text = ($num_results == 1) ? 'result' : 'results';
?>
<h1><span class="light">Searching for "</span><?php echo get_search_query(); ?><span class="light">":</span><br /><small><?php echo $num_results . ' ' . $result_text; ?></small></h1>
<hr />
<?php
// Search loop
echo '<section class="loop-wrap search-loop">';
while(have_posts()) : the_post();
$type = $post->post_type;
switch($type){
case 'product_cat':
get_template_part('loop', 'product-cat');
break;
case 'product':
get_template_part('loop', 'product');
break;
case 'post':
get_template_part('loop');
break;
case 'page':
get_template_part('loop', 'page');
break;
default:
get_template_part('loop');
break;
}
endwhile;
echo '</section>';
// Pagination
include 'pagination.php';
wp_reset_query();
?>
<?php else : ?>
<h1>No Results Found for: "<strong><?php echo get_search_query(); ?></strong>"</h1>
<hr />
<p>Sorry, but nothing matched your search criteria. Please try again with some different keywords.</p>
<div class="clear">
<?php get_search_form(); ?>
</div>
<?php endif; ?>
</div>
<div class="col span-4">
<h4>Refine Search</h4>
<form method="get" class="search-form large-search" action="<?php echo home_url( '/' ); ?>">
<input type="text" value="<?php echo get_search_query(); ?>" name="s" class="search-text" placeholder="Search" />
<button type="submit" class="search-mag" value="">
<?php e_svgi('search'); ?>
</button>
</form>
</div>
</div>
</section>
</main>
<?php get_footer(); ?>