-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp-search.php
More file actions
121 lines (101 loc) · 3.11 KB
/
Copy pathtemp-search.php
File metadata and controls
121 lines (101 loc) · 3.11 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
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
<?php /* Template Name: Search Buy */
get_header();
if (isset($_REQUEST['brand'])) {
$brand = $_REQUEST['brand'];
}
if (isset($_REQUEST['body_type'])) {
$body_type = $_REQUEST['body_type'];
}
if (isset($_REQUEST['color'])) {
$color = $_REQUEST['color'];
}
if (isset($_REQUEST['engine_type'])) {
$engine_type = $_REQUEST['engine_type'];
}
if (isset($_REQUEST['transmission'])) {
$transmission = $_REQUEST['transmission'];
}
$tax_query = array('relation' => 'AND');
if (!empty($brand)) {
$tax_query[] = array(
'taxonomy' => 'brand',
'field' => 'slug',
'terms' => $brand
);
}
if (!empty($body_type)) {
$tax_query[] = array(
'taxonomy' => 'body_type',
'field' => 'slug',
'terms' => $body_type
);
}
if (!empty($color)) {
$tax_query[] = array(
'taxonomy' => 'color',
'field' => 'slug',
'terms' => $color
);
}
if (!empty($engine_type)) {
$tax_query[] = array(
'taxonomy' => 'engine_type',
'field' => 'slug',
'terms' => $engine_type
);
}
if (!empty($transmission)) {
$tax_query[] = array(
'taxonomy' => 'transmission',
'field' => 'slug',
'terms' => $transmission
);
}
?>
<section class="search_header container mx-auto">
<a href="<?php bloginfo('url'); ?>"><img src="<?php bloginfo('template_directory'); ?>/assets/logo.png"
alt="logo" /></a>
</section>
<section class="container row mx-auto search">
<?php get_sidebar() ?>
<div class="col-md-8 col-lg-9 listing">
<div class="row _p">
<div class="col filter-responce">
<h2>Offers for Vehicles </h2>
<div class="filer_area">
<div class="filters">
<?php if (!empty($brand)) { echo "<p class='tag'>". $brand ."</p>";} ;?>
<?php if (!empty($body_type)) { echo "<p class='tag'>". $body_type ."</p>";} ;?>
<?php if (!empty($color)) { echo "<p class='tag'>". $color ."</p>";} ;?>
<?php if (!empty($transmission)) { echo "<p class='tag'>". $transmission ."</p>";} ;?>
<?php if (!empty($engine_type)) { echo "<p class='tag'>". $engine_type ."</p>";} ;?>
</div>
</div>
</div>
</div>
<?php
query_posts(
array(
'post_type' => 'vehicle',
'posts_per_page' => -1,
'order' => 'desc',
'tax_query' => $tax_query
)
);
if (have_posts()):
while (have_posts()):
the_post();
get_template_part('template-parts/vehicle', 'card');
endwhile;
wp_reset_query();
else: ?>
<div class="result-notfound">
<h2>
<?php _e('Unfortunately!, there were no results for this filter combination. Try it without the marked filter.
', 'lbt_translate'); ?>
</h2>
</div>
<?php endif; ?>
</div>
</section>
<?php get_footer(); ?>